From ae4471d4c006142f0aa968141f7d3fa8bc3257a7 Mon Sep 17 00:00:00 2001 From: Lorenzo Pichilli Date: Fri, 25 Nov 2022 12:39:04 +0100 Subject: [PATCH] Replaced Uri.encodeFull with Uri.encodeComponent to load html data correctly on Web platform --- CHANGELOG.md | 4 ++++ example/integration_test/in_app_webview/load_data.dart | 2 +- example/ios/Flutter/flutter_export_environment.sh | 5 ++--- lib/src/web/in_app_web_view_web_element.dart | 4 ++-- pubspec.yaml | 2 +- 5 files changed, 10 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 50e3e05b..3bb46ec3 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 6.0.0-beta.17 + +- Replaced `Uri.encodeFull` with `Uri.encodeComponent` to load html data correctly on Web platform + ## 6.0.0-beta.16 - Removed Android Hybrid Composition constraint to use the pull-to-refresh feature diff --git a/example/integration_test/in_app_webview/load_data.dart b/example/integration_test/in_app_webview/load_data.dart index 782f1e08..3b6dddc3 100644 --- a/example/integration_test/in_app_webview/load_data.dart +++ b/example/integration_test/in_app_webview/load_data.dart @@ -71,7 +71,7 @@ void loadData() { if (!kIsWeb) { expect(currentUrl, TEST_CROSS_PLATFORM_URL_1.toString()); } else { - expect(currentUrl, 'data:$mimeType,' + Uri.encodeFull(data)); + expect(currentUrl, 'data:$mimeType,' + Uri.encodeComponent(data)); } pageLoads.close(); diff --git a/example/ios/Flutter/flutter_export_environment.sh b/example/ios/Flutter/flutter_export_environment.sh index 70b11672..a7647f6d 100755 --- a/example/ios/Flutter/flutter_export_environment.sh +++ b/example/ios/Flutter/flutter_export_environment.sh @@ -3,12 +3,11 @@ export "FLUTTER_ROOT=/Users/lorenzopichilli/fvm/versions/3.3.6" export "FLUTTER_APPLICATION_PATH=/Users/lorenzopichilli/Desktop/flutter_inappwebview/example" export "COCOAPODS_PARALLEL_CODE_SIGN=true" -export "FLUTTER_TARGET=/Users/lorenzopichilli/Desktop/flutter_inappwebview/example/lib/main.dart" +export "FLUTTER_TARGET=lib/main.dart" export "FLUTTER_BUILD_DIR=build" export "FLUTTER_BUILD_NAME=1.0.0" export "FLUTTER_BUILD_NUMBER=1" -export "DART_DEFINES=Zmx1dHRlci5pbnNwZWN0b3Iuc3RydWN0dXJlZEVycm9ycz10cnVl,RkxVVFRFUl9XRUJfQVVUT19ERVRFQ1Q9dHJ1ZQ==" export "DART_OBFUSCATION=false" export "TRACK_WIDGET_CREATION=true" export "TREE_SHAKE_ICONS=false" -export "PACKAGE_CONFIG=/Users/lorenzopichilli/Desktop/flutter_inappwebview/example/.dart_tool/package_config.json" +export "PACKAGE_CONFIG=.dart_tool/package_config.json" diff --git a/lib/src/web/in_app_web_view_web_element.dart b/lib/src/web/in_app_web_view_web_element.dart index 46c51ad0..b57ba328 100644 --- a/lib/src/web/in_app_web_view_web_element.dart +++ b/lib/src/web/in_app_web_view_web_element.dart @@ -280,7 +280,7 @@ class InAppWebViewWebElement implements Disposable { final String contentType = httpRequest.getResponseHeader('content-type') ?? 'text/html'; return 'data:$contentType,' + - Uri.encodeFull(httpRequest.responseText ?? ''); + Uri.encodeComponent(httpRequest.responseText ?? ''); } String getIFrameId() { @@ -298,7 +298,7 @@ class InAppWebViewWebElement implements Disposable { Future loadData( {required String data, String mimeType = "text/html"}) async { - iframe.src = 'data:$mimeType,' + Uri.encodeFull(data); + iframe.src = 'data:$mimeType,' + Uri.encodeComponent(data); } Future loadFile({required String assetFilePath}) async { diff --git a/pubspec.yaml b/pubspec.yaml index d3d3979e..b76801f5 100755 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: flutter_inappwebview description: A Flutter plugin that allows you to add an inline webview, to use an headless webview, and to open an in-app browser window. -version: 6.0.0-beta.16 +version: 6.0.0-beta.17 homepage: https://inappwebview.dev/ repository: https://github.com/pichillilorenzo/flutter_inappwebview issue_tracker: https://github.com/pichillilorenzo/flutter_inappwebview/issues