Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

🐛 FIX: Double encoded ampersands in query params#929

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
sumezulike wants to merge1 commit intoexecutablebooks:master
base:master
Choose a base branch
Loading
fromsumezulike:fix-refuri-double-encoding

Conversation

sumezulike
Copy link
Contributor

Thiscloses#760.

MyST already escapes the& in the query params, but docutils escapes them again when rendering HTML, leading to broken query params.

[Link](example.com?foo=1&bar=2)

becomes

<p><ahref="example.com?foo=1&amp;amp;bar=2">Link</a></p>

instead of

<p><ahref="example.com?foo=1&amp;bar=2">Link</a></p>

These changes to the docutils parser override theHTMLTranslator.encode function so already encoded ampersands are not encoded again.
Since the issue lies in the interaction with docutils, I think it makes sense to fix it here.
Also, simply removing theescapeHtml call in MyST makes the sphinx app doctree XML files invalid because the ampersands aren't escaped.

@codecov-commenter
Copy link

codecov-commenter commentedMay 4, 2024
edited
Loading

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 90.15%. Comparing base(3d84ff8) to head(1151bee).

Additional details and impacted files
@@            Coverage Diff             @@##           master     #929      +/-   ##==========================================+ Coverage   90.13%   90.15%   +0.02%==========================================  Files          24       24                Lines        3416     3423       +7     ==========================================+ Hits         3079     3086       +7  Misses        337      337
FlagCoverage Δ
pytests90.15% <100.00%> (+0.02%)⬆️

Flags with carried forward coverage won't be shown.Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report?Share it here.

Comment on lines +272 to +275
HTMLTranslator.special_chars_no_amp= {# needed by encode_fixed
k:vfork,vinHTMLTranslator.special_characters.items()ifk!=ord("&")
}
HTMLTranslator.encode=encode_fixed
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I'm afraid this is not something that cannot be merged; it would break restructuredtext parsing.

Monkey patching is done strictly as a last resort, and only for where the patch does not affect upstream use

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@chrisjsewellchrisjsewellchrisjsewell requested changes

Requested changes must be addressed to merge this pull request.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Unable to link with multiple query params

3 participants

@sumezulike@codecov-commenter@chrisjsewell

[8]ページ先頭

©2009-2025 Movatter.jp