Skip to content

Commit

Permalink
[web] fix query editing
Browse files Browse the repository at this point in the history
  • Loading branch information
yesmeck committed Sep 9, 2022
1 parent 57c71ea commit 846159a
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 12 deletions.
20 changes: 11 additions & 9 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,25 @@
([#5465](https://github.com/mitmproxy/mitmproxy/pull/5465), @meitinger, @mhils)
* Add UDP layer and flow support.
([#5414](https://github.com/mitmproxy/mitmproxy/pull/5414), @meitinger)
* Setting `connection_strategy` to `lazy` now also disables early
* Setting `connection_strategy` to `lazy` now also disables early
upstream connections to fetch TLS certificate details.
([#5487](https://github.com/mitmproxy/mitmproxy/pull/5487), @mhils)
* Fix `tls_version_server_min` and `tls_version_server_max` options.
([#5546](https://github.com/mitmproxy/mitmproxy/issues/5546), @mhils)
* DTLS support.
* DTLS support.
([#5397](https://github.com/mitmproxy/mitmproxy/pull/5397), @kckeiks).
* Added Magisk module generation for Android onboarding
* Added Magisk module generation for Android onboarding
([#5547](https://github.com/mitmproxy/mitmproxy/pull/5547), @jorants).
* Update Linux binary builder to Ubuntu 20.04, bumping the minimum glibc version to 2.31.
* Update Linux binary builder to Ubuntu 20.04, bumping the minimum glibc version to 2.31.
([#5547](https://github.com/mitmproxy/mitmproxy/pull/5547), @jorants).
* Render application/prpc content as gRPC/Protocol Buffers
([#5568](https://github.com/mitmproxy/mitmproxy/pull/5568), @selfisekai)
* Mitmweb now supports `content_view_lines_cutoff`.
([#5548](https://github.com/mitmproxy/mitmproxy/pull/5548), @sanlengjingvv)
* Fix a mitmweb crash when scrolling down the flow list.
([#5507](https://github.com/mitmproxy/mitmproxy/pull/5507), @LIU-shuyi)
* Fix query editing on mitmweb.
([#5574](https://github.com/mitmproxy/mitmproxy/pull/5574), @yesmeck)

## 28 June 2022: mitmproxy 8.1.1

Expand Down Expand Up @@ -64,7 +66,7 @@
([#4469](https://github.com/mitmproxy/mitmproxy/issues/4469), @mhils)
* Add flatpak support to the browser addon
([#5200](https://github.com/mitmproxy/mitmproxy/issues/5200), @pauloromeira)
* Add example addon to dump contents to files based on a filter expression
* Add example addon to dump contents to files based on a filter expression
([#5190](https://github.com/mitmproxy/mitmproxy/issues/5190), @redraw)
* Fix a bug where the wrong SNI is sent to an upstream HTTPS proxy
([#5109](https://github.com/mitmproxy/mitmproxy/issues/5109), @mhils)
Expand All @@ -74,14 +76,14 @@
([#5217](https://github.com/mitmproxy/mitmproxy/issues/5217), @randomstuff)
* Improve cut addon to better handle binary contents
([#3965](https://github.com/mitmproxy/mitmproxy/issues/3965), @mhils)
* Fix text truncation for full-width characters
* Fix text truncation for full-width characters
([#4278](https://github.com/mitmproxy/mitmproxy/issues/4278), @kjy00302)
* Fix mitmweb export copy failed in non-secure domain.
([#5264](https://github.com/mitmproxy/mitmproxy/issues/5264), @Pactortester)
* Add example script for manipulating cookies.
([#5278](https://github.com/mitmproxy/mitmproxy/issues/5278), @WillahScott)
* When opening an external viewer for message contents, mailcap files are not considered anymore.
This preempts the upcoming deprecation of Python's `mailcap` module.
* When opening an external viewer for message contents, mailcap files are not considered anymore.
This preempts the upcoming deprecation of Python's `mailcap` module.
([#5297](https://github.com/mitmproxy/mitmproxy/issues/5297), @KORraNpl)
* Fix hostname encoding for IDNA domains in upstream mode.
([#5316](https://github.com/mitmproxy/mitmproxy/issues/5316), @nneonneo)
Expand Down Expand Up @@ -140,7 +142,7 @@
* Add ability to specify custom ports with LDAP authentication (#5068, @demonoidvk)
* Add support for rotating saved streams every hour or day (@EndUser509)
* Console Improvements on Windows (@mhils)
* Fix processing of `--set` options (#5067, @marwinxxii)
* Fix processing of `--set` options (#5067, @marwinxxii)
* Lowercase user-added header names and emit a log message to notify the user when using HTTP/2 (#4746, @mhils)
* Exit early if there are errors on startup (#4544, @mhils)
* Fixed encoding guessing: only search for meta tags in HTML bodies (##4566, @Prinzhorn)
Expand Down
2 changes: 2 additions & 0 deletions mitmproxy/tools/web/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,8 @@ def put(self, flow_id):
request.trailers.add(*trailer)
elif k == "content":
request.text = v
elif k == "query":
request.query = [tuple(i) for i in v]
else:
raise APIError(400, f"Unknown update request.{k}: {v}")

Expand Down
18 changes: 15 additions & 3 deletions web/src/js/components/contentviews/HttpMessage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,13 @@ export default function HttpMessage({flow, message}: HttpMessageProps) {
} else {
url = MessageUtils.getContentURL(flow, message, contentView, maxLines + 1);
}
const content = useContent(url, message.contentHash);
let content = useContent(url, message.contentHash);
if (flow.request.method === "GET" && edit) {
const params = new URLSearchParams(new URL(`${flow.request.scheme}://${flow.request.path}`).search);
content = Array.from(params.entries())
.reduce((acc, [key, value]) => [...acc, `${key}=${value}`], [])
.join("\n");
}
const contentViewData = useMemo<ContentViewData | undefined>(() => {
if (content && !edit) {
try {
Expand All @@ -48,8 +54,14 @@ export default function HttpMessage({flow, message}: HttpMessageProps) {

if (edit) {
const save = async () => {
const content = editorRef.current?.getContent();
await dispatch(flowActions.update(flow, {[part]: {content}}));
let content = editorRef.current?.getContent();
await dispatch(flowActions.update(flow, {
[part]: flow.request.method === 'GET' ? {
query: content?.split("\n").map(item => item.split('='))
}: {
content
}
}));
setEdit(false);
}
return (
Expand Down

0 comments on commit 846159a

Please sign in to comment.