Skip to content

Prusalink: Add missing urlencode, fix bounds check and add url tests#5184

Open
bkerler wants to merge 2 commits intoprusa3d:masterfrom
bkerler:js_issue
Open

Prusalink: Add missing urlencode, fix bounds check and add url tests#5184
bkerler wants to merge 2 commits intoprusa3d:masterfrom
bkerler:js_issue

Conversation

@bkerler
Copy link
Copy Markdown

@bkerler bkerler commented Mar 22, 2026

This solves issue #5112. If files with percent sign are being uploaded, these aren't url encoded as they should be.
The second commit makes sure that the url_decode bounds check is handled properly and that if percent signs are used, they are identified as special characters correctly if applicable (percent-encoded sequence). To make sure that everything works correctly, tests have been added (here: claude code has been used for implementing the tests).

This PR requires prior adaption of prusa3d/Prusa-Link-Web#525

bkerler added 2 commits March 22, 2026 16:55
The previous bounds check compared the output buffer size against
an input string position, which is a category error. It has been
replaced with a proper check that verifies whether two further
input characters are available to complete a %XX sequence.

Additionally, the decoder now treats a '%' that is not followed by
exactly two valid hex digits as a literal '%' character instead of
returning an error. This makes the server resilient against clients
that do not percent-encode special characters in URL paths.

Fixes prusa3d#5112
Cover the three cases relevant to filenames containing '%':
- '%' at the end of the URL (no following characters)
- '%' followed by non-hex characters (e.g. "file50%.gcode")
- '%' properly encoded as '%25', which must still decode to '%'
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.

1 participant