fix(url): double-encode dots as %252E for NGINX compatibility#1493
fix(url): double-encode dots as %252E for NGINX compatibility#1493matteotrubini wants to merge 1 commit into
Conversation
In certain NGINX configurations, unencoded dots in URLs may trigger asset-serving rules, resulting in 404 errors. rawurlencode() skips dots, but RFC 3986 allows dot encoding, so we manually double-encode them.
WalkthroughIn Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@modules/system/classes/ImageResizer.php`:
- Around line 586-588: The identifier generation in the ImageResizer class is
based on the original URL with unencoded dots, but the actual encoded URL being
sent has dots replaced with %252E. This causes a validation mismatch in
getValidResizedUrl() where the hash comparison fails because the identifier was
generated from a different URL format than what is being validated. Move the
identifier generation (the hash_hmac call that creates the identifier) to occur
AFTER the dot replacement on line 588, so that the identifier is computed from
the modified $resizedUrl that contains %252E instead of literal dots, ensuring
consistency between the encoded URL and its corresponding identifier throughout
the validation process.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 0542cb98-530f-4e7b-a547-f06ab95ca767
📒 Files selected for processing (1)
modules/system/classes/ImageResizer.php
In certain NGINX configurations, unencoded dots in URLs may trigger asset-serving rules, resulting in 404 errors. rawurlencode() skips dots, but RFC 3986 allows dot encoding, so we manually double-encode them.
Summary by CodeRabbit