]> git.ipfire.org Git - thirdparty/rspamd.git/commit
[Fix] Encode redirect URLs to handle unencoded spaces and special characters 5748/head
authorVsevolod Stakhov <vsevolod@rspamd.com>
Sat, 15 Nov 2025 15:53:17 +0000 (15:53 +0000)
committerVsevolod Stakhov <vsevolod@rspamd.com>
Sat, 15 Nov 2025 15:53:17 +0000 (15:53 +0000)
commitf7ef4ac9aad5ac455986b960b3f75e94dd137a7d
treedd6e72a872e0c47b1bf787a710f1510ac6972266
parent0f791f94142e81d7d0ac8d9a4ba31919c838a2c5
[Fix] Encode redirect URLs to handle unencoded spaces and special characters

This fixes issue #5525 where url_redirector fails when redirect Location
headers contain unencoded spaces or other special characters.

The http_parser_parse_url() function strictly requires percent-encoded URLs
per RFC 3986, but many servers send Location headers with unencoded spaces.

Changes:
- Add encode_url_for_redirect() function to percent-encode problematic characters
- Apply encoding to redirect Location headers before creating URL objects
- Preserve already-encoded sequences (no double-encoding)
- Log warnings for URLs that fail even after encoding

The fix is conservative - only encodes characters that http_parser rejects,
maintaining full backward compatibility with properly formatted URLs.

Closes: #5525
src/plugins/lua/url_redirector.lua