Skip to content

[share_plus] Linux and Web share URL is constructed incorrectly #235

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

Closed
stuartmorgan-g opened this issue May 12, 2021 · 2 comments · Fixed by #236
Closed

[share_plus] Linux and Web share URL is constructed incorrectly #235

stuartmorgan-g opened this issue May 12, 2021 · 2 comments · Fixed by #236
Labels
bug Something isn't working linux share_plus Feature, Enhancement, Bug Fixes for Share Plus Plugin web windows

Comments

@stuartmorgan-g
Copy link

This line:

final uri = Uri.encodeFull('mailto:?subject=$subject&body=$text');

is constructing the URL incorrectly; you cannot concatenated unencoded elements together in a query string and then encodeFull it and get the right result, because some characters that are valid in a URL in general—notably &—are not valid in a query argument. If you want to construct a URL with query parameters manually, you need to encode the components explicitly.

Compare:

final subject = 'This & That';
final text = 'More & more';

// Incorrect:
print(Uri.encodeFull('mailto:?subject=$subject&body=$text'));
// -> mailto:?subject=This%20&%20That&body=More%20&%20more

// Correct:
print('mailto:?subject=${Uri.encodeComponent(subject)}&body=${Uri.encodeComponent(text)}');
// -> mailto:?subject=This%20%26%20That&body=More%20%26%20more

The first will result in an email whose subject is "That " and whose body is "More ".

@stuartmorgan-g stuartmorgan-g added the bug Something isn't working label May 12, 2021
@miquelbeltran miquelbeltran added linux share_plus Feature, Enhancement, Bug Fixes for Share Plus Plugin labels May 12, 2021
@stuartmorgan-g
Copy link
Author

Just noticed that this same pattern is used in the web version.

@stuartmorgan-g stuartmorgan-g changed the title [share_plus] Linux share URL is constructed incorrectly [share_plus] Linux and Web share URL is constructed incorrectly May 12, 2021
@miquelbeltran
Copy link
Member

this should be fixed in share_plus_web 2.0.3, share_plus_linux 2.0.2 and share_plus_windows 2.0.2

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 31, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working linux share_plus Feature, Enhancement, Bug Fixes for Share Plus Plugin web windows
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants