Skip to content
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

Fix href sanitization bugs #103

Merged
merged 1 commit into from Aug 13, 2020
Merged

Fix href sanitization bugs #103

merged 1 commit into from Aug 13, 2020

Conversation

fewstera
Copy link
Contributor

This PR fixes two issues.

The first issue is that if you have two query params with the same name, only the last param is included in the sanitized result. See the following test case for an example.

    TestLinks: sanitize_test.go:171: test 9 failed;
        input   : <a href="?q=1&q=2">
        output  : <a href="?q=2" rel="nofollow">
        expected: <a href="?q=1&q=2" rel="nofollow">

The second issue this PR fixes is that characters inside the query params are HTML encoded. Take the following query.

?json=%7B%22value%22%3A%22a%22%7D

key value
json {"value":"a"}

After sanitization the query becomes the following, which is a bug as the query is no longer valid JSON.:

?json=%7B%26%2334%3Bvalue%26%2334%3B%3A%26%2334%3Ba%26%2334%3B%7D

key value
json {&#34;value&#34;:&#34;a&#34;}

@buro9
Copy link
Member

buro9 commented Aug 13, 2020

This is a nice catch, and a great PR. Thanks 👍

@buro9 buro9 merged commit 3cce251 into microcosm-cc:master Aug 13, 2020
@fewstera
Copy link
Contributor Author

Thank you for the quick review & merge @buro9.

Do you mind releasing a new version with this fix too please?

@buro9
Copy link
Member

buro9 commented Aug 13, 2020

Published

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.

None yet

2 participants