diff --git a/packages/share_plus_linux/CHANGELOG.md b/packages/share_plus_linux/CHANGELOG.md index 4dd003af12..2a6c9d3133 100644 --- a/packages/share_plus_linux/CHANGELOG.md +++ b/packages/share_plus_linux/CHANGELOG.md @@ -1,3 +1,7 @@ +## 2.0.3 + +- Hotfix on 2.0.2, improved solution. + ## 2.0.2 - Fixes: share URL is constructed incorrectly #235 diff --git a/packages/share_plus_linux/lib/share_plus_linux.dart b/packages/share_plus_linux/lib/share_plus_linux.dart index 0724b9d2da..cdbdcc55e3 100644 --- a/packages/share_plus_linux/lib/share_plus_linux.dart +++ b/packages/share_plus_linux/lib/share_plus_linux.dart @@ -20,9 +20,13 @@ class ShareLinux extends SharePlatform { 'body': text, }; + // see https://github.com/dart-lang/sdk/issues/43838#issuecomment-823551891 final uri = Uri( scheme: 'mailto', - queryParameters: queryParameters, + query: queryParameters.entries + .map((e) => + '${Uri.encodeComponent(e.key)}=${Uri.encodeComponent(e.value)}') + .join('&'), ); if (await canLaunch(uri.toString())) { diff --git a/packages/share_plus_linux/pubspec.yaml b/packages/share_plus_linux/pubspec.yaml index 66629f4e0d..9cca4d9c70 100644 --- a/packages/share_plus_linux/pubspec.yaml +++ b/packages/share_plus_linux/pubspec.yaml @@ -1,6 +1,6 @@ name: share_plus_linux description: Linux implementation of the share_plus plugin -version: 2.0.2 +version: 2.0.3 homepage: https://plus.fluttercommunity.dev/ repository: https://github.com/fluttercommunity/plus_plugins/tree/main/packages/ diff --git a/packages/share_plus_linux/test/share_plus_linux_test.dart b/packages/share_plus_linux/test/share_plus_linux_test.dart index 280c8b1bd9..4bfe6926a6 100644 --- a/packages/share_plus_linux/test/share_plus_linux_test.dart +++ b/packages/share_plus_linux/test/share_plus_linux_test.dart @@ -4,7 +4,7 @@ import 'package:url_launcher_platform_interface/url_launcher_platform_interface. import 'package:url_launcher_platform_interface/link.dart'; void main() { - test('url encoding is correct', () async { + test('url encoding is correct for &', () async { final mock = MockUrlLauncherPlatform(); UrlLauncherPlatform.instance = mock; @@ -13,6 +13,16 @@ void main() { expect(mock.url, 'mailto:?subject=bar%26foo&body=foo%26bar'); }); + // see https://github.com/dart-lang/sdk/issues/43838#issuecomment-823551891 + test('url encoding is correct for spaces', () async { + final mock = MockUrlLauncherPlatform(); + UrlLauncherPlatform.instance = mock; + + await ShareLinux().share('foo bar', subject: 'bar foo'); + + expect(mock.url, 'mailto:?subject=bar%20foo&body=foo%20bar'); + }); + test('throws when url_launcher can\'t launch uri', () async { final mock = MockUrlLauncherPlatform(); mock.canLaunchMockValue = false; diff --git a/packages/share_plus_web/CHANGELOG.md b/packages/share_plus_web/CHANGELOG.md index 1b8976a581..3718dae83b 100644 --- a/packages/share_plus_web/CHANGELOG.md +++ b/packages/share_plus_web/CHANGELOG.md @@ -1,3 +1,7 @@ +## 2.0.4 + +- Hotfix on 2.0.3, improved solution. + ## 2.0.3 - Fix #235: share URL is constructed incorrectly diff --git a/packages/share_plus_web/lib/share_plus_web.dart b/packages/share_plus_web/lib/share_plus_web.dart index e4324e23bf..ae256beb9f 100644 --- a/packages/share_plus_web/lib/share_plus_web.dart +++ b/packages/share_plus_web/lib/share_plus_web.dart @@ -35,9 +35,13 @@ class SharePlusPlugin extends SharePlatform { 'body': text, }; + // see https://github.com/dart-lang/sdk/issues/43838#issuecomment-823551891 final uri = Uri( scheme: 'mailto', - queryParameters: queryParameters, + query: queryParameters.entries + .map((e) => + '${Uri.encodeComponent(e.key)}=${Uri.encodeComponent(e.value)}') + .join('&'), ); if (await canLaunch(uri.toString())) { diff --git a/packages/share_plus_web/pubspec.yaml b/packages/share_plus_web/pubspec.yaml index 33356c89ea..dbf932c138 100644 --- a/packages/share_plus_web/pubspec.yaml +++ b/packages/share_plus_web/pubspec.yaml @@ -2,7 +2,7 @@ name: share_plus_web description: Web platform implementation of share_plus homepage: https://plus.fluttercommunity.dev/ repository: https://github.com/fluttercommunity/plus_plugins/tree/main/packages/ -version: 2.0.3 +version: 2.0.4 flutter: plugin: diff --git a/packages/share_plus_windows/CHANGELOG.md b/packages/share_plus_windows/CHANGELOG.md index 6095aeaeb7..64c253269f 100644 --- a/packages/share_plus_windows/CHANGELOG.md +++ b/packages/share_plus_windows/CHANGELOG.md @@ -1,3 +1,7 @@ +## 2.0.3 + +- Hotfix on 2.0.2, improved solution. + ## 2.0.2 - Fixes: share URL is constructed incorrectly #235 diff --git a/packages/share_plus_windows/lib/share_plus_windows.dart b/packages/share_plus_windows/lib/share_plus_windows.dart index f5650445fa..ba7a1807cd 100644 --- a/packages/share_plus_windows/lib/share_plus_windows.dart +++ b/packages/share_plus_windows/lib/share_plus_windows.dart @@ -20,9 +20,13 @@ class ShareWindows extends SharePlatform { 'body': text, }; + // see https://github.com/dart-lang/sdk/issues/43838#issuecomment-823551891 final uri = Uri( scheme: 'mailto', - queryParameters: queryParameters, + query: queryParameters.entries + .map((e) => + '${Uri.encodeComponent(e.key)}=${Uri.encodeComponent(e.value)}') + .join('&'), ); if (await canLaunch(uri.toString())) { diff --git a/packages/share_plus_windows/pubspec.yaml b/packages/share_plus_windows/pubspec.yaml index b4d382e532..b0f74d9736 100644 --- a/packages/share_plus_windows/pubspec.yaml +++ b/packages/share_plus_windows/pubspec.yaml @@ -1,6 +1,6 @@ name: share_plus_windows description: Windows implementation of the share_plus plugin -version: 2.0.2 +version: 2.0.3 homepage: https://plus.fluttercommunity.dev/ repository: https://github.com/fluttercommunity/plus_plugins/tree/main/packages/ diff --git a/packages/share_plus_windows/test/share_plus_windows_test.dart b/packages/share_plus_windows/test/share_plus_windows_test.dart index 48c2cb4a2b..8f009fa02f 100644 --- a/packages/share_plus_windows/test/share_plus_windows_test.dart +++ b/packages/share_plus_windows/test/share_plus_windows_test.dart @@ -4,7 +4,7 @@ import 'package:url_launcher_platform_interface/url_launcher_platform_interface. import 'package:url_launcher_platform_interface/link.dart'; void main() { - test('url encoding is correct', () async { + test('url encoding is correct for &', () async { final mock = MockUrlLauncherPlatform(); UrlLauncherPlatform.instance = mock; @@ -13,6 +13,16 @@ void main() { expect(mock.url, 'mailto:?subject=bar%26foo&body=foo%26bar'); }); + // see https://github.com/dart-lang/sdk/issues/43838#issuecomment-823551891 + test('url encoding is correct for spaces', () async { + final mock = MockUrlLauncherPlatform(); + UrlLauncherPlatform.instance = mock; + + await ShareWindows().share('foo bar', subject: 'bar foo'); + + expect(mock.url, 'mailto:?subject=bar%20foo&body=foo%20bar'); + }); + test('throws when url_launcher can\'t launch uri', () async { final mock = MockUrlLauncherPlatform(); mock.canLaunchMockValue = false;