Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only allow DartPad injection from window.parent #2993

Closed
wants to merge 17 commits into from
1 change: 1 addition & 0 deletions pkgs/dartpad_ui/lib/embed.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ void handleEmbedMessage(AppModel model) {
web.window.addEventListener(
'message',
(web.MessageEvent event) {
if (event.source != web.window.parent) return;
if (event.data case _SourceCodeMessage(:final type?, :final sourceCode?)
when type == 'sourceCode') {
if (sourceCode.isNotEmpty) {
Expand Down
3 changes: 3 additions & 0 deletions pkgs/dartpad_ui/lib/execution/frame.dart
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,9 @@ require(["dartpad_main", "dart_sdk"], function(dartpad_main, dart_sdk) {
if (data['sender'] != 'frame') {
return;
}
if (event.source == null || _frame.contentWindow != event.source) {
return;
}
final type = data['type'] as String?;

if (type == 'stderr') {
Expand Down