Repository navigation
fix: pull files with non-ASCII characters in the path - #2871
Open
tonyandrewmeyer wants to merge 4 commits into
Open
tonyandrewmeyer wants to merge 4 commits into
tonyandrewmeyer wants to merge 4 commits into
Conversation
The multipart headers were parsed as bytes, and the email bytes parser replaces anything outside ASCII in a header value, so the filename no longer matched and pull() failed with "path not expected". Pebble writes the raw UTF-8 path, so the header bytes are now decoded as UTF-8 first. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
benhoyt
reviewed
Nov 9, 2026
| # The bytes parser replaces anything outside ASCII in a header value, | ||
| # which loses a non-ASCII path. Pebble sends the headers as UTF-8. | ||
| parser = email.parser.FeedParser() | ||
| parser.feed(data.decode('utf-8', 'surrogateescape')) |
Collaborator
There was a problem hiding this comment.
I agree with the intent here, but I just want to make sure that this will still allow arbitrary binary bytes in the file payload part of the HTTP response.
Collaborator
Author
There was a problem hiding this comment.
Yes, only the part headers go through the decode: _MultipartParser splits each part at the first \r\n\r\n, hands the header block to _process_header, and passes the body bytes to _process_body untouched, which writes them straight to the tempfile. I've extended test_pull_binary with some bytes that aren't valid UTF-8 (\xff\xfe\x00\x80) to ensure it stays that way.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MattPatchava
approved these changes
Nov 12, 2026
Message.get_filename() strips whitespace from both ends of the filename, so
pulling a path that ends in a space or tab got a name that didn't match the
requested path, and raised ProtocolError('path not expected'). Read the
filename parameter directly instead.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
pull()of a path containing non-ASCII characters failed with "path not expected", because the multipart headers were parsed as bytes and the email parser replaces anything outside ASCII in them. The header bytes are now decoded as UTF-8 first.Pebble's
api_files.gouses Go'sCreateFormFile, which writes the raw UTF-8 path into thefilenameparameter.