Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit c5be9d7

Browse files
committed
Log errors on malformed messages
1 parent 976203e commit c5be9d7

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

shell/platform/windows/accessibility_plugin.cc

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
#include <variant>
88

9+
#include "flutter/fml/logging.h"
910
#include "flutter/fml/platform/win/wstring_conversion.h"
1011
#include "flutter/shell/platform/common/client_wrapper/include/flutter/standard_message_codec.h"
1112
#include "flutter/shell/platform/windows/flutter_windows_engine.h"
@@ -26,16 +27,27 @@ static constexpr char kAnnounceValue[] = "announce";
2627
void HandleMessage(AccessibilityPlugin* plugin, const EncodableValue& message) {
2728
const auto* map = std::get_if<EncodableMap>(&message);
2829
if (!map) {
30+
FML_LOG(ERROR) << "Accessibility message must be a map.";
2931
return;
3032
}
3133
const auto& type_itr = map->find(EncodableValue{kTypeKey});
3234
const auto& data_itr = map->find(EncodableValue{kDataKey});
33-
if (type_itr == map->end() || data_itr == map->end()) {
35+
if (type_itr == map->end()) {
36+
FML_LOG(ERROR) << "Accessibility message must have a 'type' property.";
37+
return;
38+
}
39+
if (data_itr == map->end()) {
40+
FML_LOG(ERROR) << "Accessibility message must have a 'data' property.";
3441
return;
3542
}
3643
const auto* type = std::get_if<std::string>(&type_itr->second);
3744
const auto* data = std::get_if<EncodableMap>(&data_itr->second);
38-
if (!type || !data) {
45+
if (!type) {
46+
FML_LOG(ERROR) << "Accessibility message 'type' property must be a string.";
47+
return;
48+
}
49+
if (!data) {
50+
FML_LOG(ERROR) << "Accessibility message 'data' property must be a map.";
3951
return;
4052
}
4153

@@ -50,6 +62,9 @@ void HandleMessage(AccessibilityPlugin* plugin, const EncodableValue& message) {
5062
}
5163

5264
plugin->Announce(*message);
65+
} else {
66+
FML_LOG(ERROR) << "Accessibility message type '" << *type
67+
<< "' is not supported.";
5368
}
5469
}
5570

0 commit comments

Comments
 (0)