Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add mapremote addon to modify request URLs #4060

Merged
merged 3 commits into from Jul 3, 2020

Conversation

mplattner
Copy link
Member

@mplattner mplattner commented Jul 3, 2020

Description

Added a new addon (MapRemote) to rewrite URLs of requests before the request is performed.

refs #3948

Checklist

  • I have updated tests where applicable.
  • I have added an entry to the CHANGELOG.

@mplattner mplattner requested a review from mhils July 3, 2020 12:37
Copy link
Member

@mhils mhils left a comment

Choose a reason for hiding this comment

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

Nice! This looks pretty much ready to merge except for the encoding changes.

return

replacements = 0
obj.url, replacements = re.subn(search, repl, strutils.escaped_str_to_bytes(obj.pretty_url), flags=re.DOTALL)
Copy link
Member

Choose a reason for hiding this comment

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

The URL is surrogate-escaped UTF-8, so we should do obj.pretty_url.encode("utf8", "surrogateescape"). We're doing a bit of a weird encoding dance here that's tricky to explain, but escaped_str_to_bytes would interpret escape sequences in a URL as raw bytes, which would fail in some edge cases.

Copy link
Member Author

Choose a reason for hiding this comment

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

Do you think this is what causes the failing unit test on windows? (e.g. TestMapRemoteFile; see #4046 (comment))

@mhils mhils merged commit cf15802 into mitmproxy:master Jul 3, 2020
@Prinzhorn Prinzhorn mentioned this pull request Jul 15, 2020
2 tasks
@mplattner mplattner added the gsoc Google Summer of Code label Sep 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
gsoc Google Summer of Code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants