Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Log errors on malformed messages
  • Loading branch information
loic-sharma committed Feb 26, 2024
commit c5be9d79e3c55835ece522bd8e3b8261ee19f529
19 changes: 17 additions & 2 deletions shell/platform/windows/accessibility_plugin.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

#include <variant>

#include "flutter/fml/logging.h"
#include "flutter/fml/platform/win/wstring_conversion.h"
#include "flutter/shell/platform/common/client_wrapper/include/flutter/standard_message_codec.h"
#include "flutter/shell/platform/windows/flutter_windows_engine.h"
Expand All @@ -26,16 +27,27 @@ static constexpr char kAnnounceValue[] = "announce";
void HandleMessage(AccessibilityPlugin* plugin, const EncodableValue& message) {
const auto* map = std::get_if<EncodableMap>(&message);
if (!map) {
FML_LOG(ERROR) << "Accessibility message must be a map.";
return;
}
const auto& type_itr = map->find(EncodableValue{kTypeKey});
const auto& data_itr = map->find(EncodableValue{kDataKey});
if (type_itr == map->end() || data_itr == map->end()) {
if (type_itr == map->end()) {
FML_LOG(ERROR) << "Accessibility message must have a 'type' property.";
return;
}
if (data_itr == map->end()) {
FML_LOG(ERROR) << "Accessibility message must have a 'data' property.";
return;
}
const auto* type = std::get_if<std::string>(&type_itr->second);
const auto* data = std::get_if<EncodableMap>(&data_itr->second);
if (!type || !data) {
if (!type) {
FML_LOG(ERROR) << "Accessibility message 'type' property must be a string.";
return;
}
if (!data) {
FML_LOG(ERROR) << "Accessibility message 'data' property must be a map.";
return;
}

Expand All @@ -50,6 +62,9 @@ void HandleMessage(AccessibilityPlugin* plugin, const EncodableValue& message) {
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yaakovschectman following up on this conversation: #50898 (comment)

I added error logs for malformed top-level type and data properties. I kept the plugin "flexible" on the announcement message's inner message data property, similar to other embedders' logic.


plugin->Announce(*message);
} else {
FML_LOG(ERROR) << "Accessibility message type '" << *type
<< "' is not supported.";
}
}

Expand Down