caddy icon indicating copy to clipboard operation
caddy copied to clipboard

rewrite: Add option to force modifying the query

Open francislavoie opened this issue 2 years ago • 1 comments

Fix #5208

When a user wants to rewrite the URI, if they use a placeholder which might contain both the path and query, currently only the path portion of the placeholder will be used and the query is discarded.

This isn't ideal when the placeholder input comes from, for example, a response header from upstream when doing X-Accel-Redirect style intercepting of the response.

To work around this, we can add an option to force-enable query modifications, essentially marking the configured placeholder input as "trusted" in the sense that it's expected to contain a valid query part and not an injected ? via URL encoding.

I'm not sure the implementation is completely correct. There's a test case I'm not quite sure how we want to handle, i.e. the placeholder only having a query and no path. Is that something we care to support? If not I can remove that TODO comment.

francislavoie avatar Mar 16 '23 21:03 francislavoie

Thanks for proposing this Francis, I'll try to get around to reviewing this soon. (Sorry for the delay. I'm also curious about this versus #5504)

mholt avatar May 11 '23 20:05 mholt