Skip to content

Add uri-encoding to StreamUri::toString() #1398

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

Merged
merged 3 commits into from
Jul 29, 2025

Conversation

gnumpi
Copy link
Contributor

@gnumpi gnumpi commented Jul 17, 2025

When adding a stream to a Snapcast server that includes a control parameter with associated arguments, it's essential that the reconstructed URI is properly URL-encoded after verifying or modifying the control script's location.

This PR is a suggestion for addressing this issue.


Pull Request Checklist

  • Contributions must be licensed under the GPL-3.0 License

  • This project loosely follows the Google C++ Style Guide

  • For better compatibility with embedded toolchains, the used C++ standard should be limited to C++17

  • Code should be formatted by running make reformat

  • Branch from the develop branch and ensure it is up to date with the current develop branch before submitting your pull request. If it doesn't merge cleanly with develop, you may be asked to resolve the conflicts. Pull requests to master will be closed.

  • Commits should be as small as possible while ensuring that each commit is correct independently (i.e., each commit should compile and pass tests).

  • Pull requests must not contain compiled sources (already set by the default .gitignore) or binary files

  • Test your changes as thoroughly as possible before you commit them. Preferably, automate your test by unit/integration tests. If tested manually, provide information about the test scope in the PR description (e.g. “Test passed: Upgrade version from 0.42 to 0.42.23.”).

  • Create Work In Progress [WIP] pull requests only if you need clarification or an explicit review before you can continue your work item.

  • If your patch is not getting reviewed or you need a specific person to review it, you can @-reply a reviewer asking for a review in the pull request or a comment, or you can ask for a review by contacting us via email.

  • Post review:

    • If a review requires you to change your commit(s), please test the changes again.
    • Amend the affected commit(s) and force push onto your branch.
    • Set respective comments in your GitHub review to resolved.
    • Create a general PR comment to notify the reviewers that your amendments are ready for another round of review.

@badaix
Copy link
Owner

badaix commented Jul 28, 2025

Thanks! Could you please add unit tests with examples StreamURIs that test converting forth and back?

@gnumpi
Copy link
Contributor Author

gnumpi commented Jul 28, 2025

Thanks! Could you please add unit tests with examples StreamURIs that test converting forth and back?

Sure, I will extend the URI test case.

In your tests, you're using a test string for URL encoding that doesn't form a valid URI. As I understand it, both the scheme and host parts of a URI must be alphanumeric (and follow standard URI syntax).

Is this use of non-standard characters intentional? Does the Snapcast server configuration rely on an extended URL format that allows percent-encoding in the scheme or host sections?

StreamUri("scheme%26://%26host%3f:23/pa%2Bth?%21%23%24%25%26%27%28%29=%2A%2B%2C%2F%3A%3B%3D%3F%40%5B%5D&key%2525=value#fragment%3f%21%3F")``

@gnumpi
Copy link
Contributor Author

gnumpi commented Jul 28, 2025

I chose to update the test URL string to a standards-compliant format in order to properly test the URL encoding behavior.

Please let me know if you're okay with this approach or if you'd prefer to retain the original string for a specific reason.

@badaix
Copy link
Owner

badaix commented Jul 29, 2025

Awesome, thanks!

@badaix badaix merged commit f1c2f74 into badaix:develop Jul 29, 2025
57 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants