-
Notifications
You must be signed in to change notification settings - Fork 9.7k
[webview_flutter] fix: unreliable encoding for web #5737
Changes from 4 commits
f8e51ad
e9dfa1f
e0b13de
0b61f9c
99b5c76
5781562
397f609
42bf109
db3c42a
5d9e7c1
15deea5
b760936
d2704ed
7df9cfa
95fd76b
d62c793
c1c4884
61c0028
902e8f3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
import 'dart:convert'; | ||
import 'dart:html'; | ||
import 'dart:typed_data'; | ||
|
||
|
@@ -64,7 +65,11 @@ void main() { | |
// Run | ||
controller.loadHtmlString('test html'); | ||
// Verify | ||
verify(mockElement.src = 'data:text/html,${Uri.encodeFull('test html')}'); | ||
verify(mockElement.src = Uri.dataFromString( | ||
'test html', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These test cases don't actually exercise the problem described in your issue. Would either of these even fail if you reverted the non-test changes? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The tests wouldn't pass before this PR's changes because instead of starting the It would be more accurate for the test to only check if the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That test failure would have nothing to do with the issue you fixed. I could make these tests pass without fixing the bug by just adding The issue you are fixing is about properly escaping special characters--specifically There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (In fact, the changelog should say "incorrect escaping", not "unreliable encoding", since this is about escaping rather than encoding.) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You're right I'll fix the test to include the new escaping. But should it be renamed to only fix escaping even though it adds the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you want to also mention adding explicit encoding as a secondary change, feel free. But there have been zero reports of encoding issues so it's not particularly important to mention. |
||
mimeType: 'text/html', | ||
encoding: Encoding.getByName('utf-8'), | ||
).toString()); | ||
}); | ||
|
||
group('loadRequest', () { | ||
FlafyDev marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
@@ -122,8 +127,11 @@ void main() { | |
requestHeaders: <String, String>{'Foo': 'Bar'}, | ||
sendData: Uint8List.fromList('test body'.codeUnits), | ||
)); | ||
verify( | ||
mockElement.src = 'data:text/plain,${Uri.encodeFull('test data')}'); | ||
verify(mockElement.src = Uri.dataFromString( | ||
'test data', | ||
mimeType: 'text/plain', | ||
encoding: Encoding.getByName('utf-8'), | ||
).toString()); | ||
}); | ||
}); | ||
}); | ||
|
Uh oh!
There was an error while loading. Please reload this page.