Skip to content

Only drop trailing blank lines when cleaning URLs - #1046

Merged
jacebrowning merged 1 commit into
jacebrowning:mainfrom
Sanjays2402:fix/trailing-blank-line-collapse
Jul 26, 2026
Merged

Only drop trailing blank lines when cleaning URLs#1046
jacebrowning merged 1 commit into
jacebrowning:mainfrom
Sanjays2402:fix/trailing-blank-line-collapse

Conversation

@Sanjays2402

Copy link
Copy Markdown
Contributor

Closes #871

clean() replaced every /_. in the URL with ., not just the trailing one, so /images/vince/a/_.b/c-d.png (where the second line is a blank line followed by text starting with a dot) collapsed to /images/vince/a.b/c-d.png and redirected to the wrong image. Anchoring the substitution to the extension at the end of the path removes only genuinely trailing blank lines.

The trailing-blank-line cleanup replaced every '/_.' in the URL with
'.', not just the one at the end of the path. A URL like
/images/vince/a/_.b/c-d.png, where '_' starts a middle text line whose
content begins with a dot, was collapsed to /images/vince/a.b/c-d.png,
merging two separate text lines and redirecting to the wrong image.

Anchor the substitution to the extension at the end of the path so only
genuinely trailing blank lines are removed.

Adds app/tests/test_utils_urls.py covering both the dropped trailing
blanks and the preserved mid-path blank line.
@jacebrowning
jacebrowning temporarily deployed to memegen-pr-1046 July 26, 2026 01:47 Inactive

@jacebrowning jacebrowning left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Thanks!

@jacebrowning
jacebrowning merged commit db28f53 into jacebrowning:main Jul 26, 2026
3 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.

Combination of underscore and dash incorrectly redirects

2 participants