Ottomata has submitted this change and it was merged.
Change subject: Fix double encoded characters in gitweb -> gitblit forwards
......................................................................
Fix double encoded characters in gitweb -> gitblit forwards
The combination of 'AllowEncodedSlashes On' and [B] caused '/' in
project names to be translated into '%252f' ('/' encoded twice)
instead of '%2f' ('/' encoded once). As the RewriteRule's
replacement's backreferences get escaped through [B], and the
remaining parts are plain harmless strings, we turn off encoding of
the rewritten URL.
Bug: 41961
Change-Id: I949fc00341d08147ad72cdb860526a7dbcd9dc83
---
M templates/apache/sites/gerrit.wikimedia.org.erb
1 file changed, 11 insertions(+), 8 deletions(-)
Approvals:
Ottomata: Verified; Looks good to me, approved
diff --git a/templates/apache/sites/gerrit.wikimedia.org.erb
b/templates/apache/sites/gerrit.wikimedia.org.erb
index 68f7fad..5cfafac 100644
--- a/templates/apache/sites/gerrit.wikimedia.org.erb
+++ b/templates/apache/sites/gerrit.wikimedia.org.erb
@@ -103,12 +103,15 @@
#
# Notes
# 1. gitblit requires URL-encoding (%2F) of the slashes in the matched
- # paths to project and file. The [B] option together with
- # 'AllowEncodedSlashes NoDecode' does this; it also converts '.' in
- # .git and .php to "%2e" , gitblit accepts this. (If this causes
- # problems with other URLs you could use
- # RewriteMap esc int:escape
- # and ${esc:%1} for the paths, and probably have to add [noescape]
option).
+ # paths to project and file. The [B] option does this for the
+ # backreferences; it also converts '.' in .git and .php to "%2e",
gitblit
+ # accepts this. Due to the additional 'AllowEncodedSlashes On' (which
+ # is a requirement from gerrit's suggested reverse proxy configuration),
+ # the '%' in these '%2f', '%2e', ... get encoded themselves, and we end
up
+ # seeing double encoded characters '%252f', '%252e', ... . To prohibit
+ # this final (unneeded, since backreferences get encoded, and the other
URL
+ # parts should be safe, as they are plain literals) encoding, we add
[NE]
+ # to the options.
# 2. Append an empty query string (which mod_rewrite is smart enough to
# drop), otherwise the original query string is appended -- mod_rewrite
# lacks a DiscardQueryString option.
@@ -125,11 +128,11 @@
# Rewrite a gitweb project link (no file).
RewriteCond ;%{QUERY_STRING} !;f=
RewriteCond ;%{QUERY_STRING} ;p=([^;]*)
- RewriteRule ^/r/gitweb$ https://git.wikimedia.org/summary/%1/HEAD?
[R=301,L,B]
+ RewriteRule ^/r/gitweb$ https://git.wikimedia.org/summary/%1/HEAD?
[R=301,L,B,NE]
# Rewrite a gitweb file link (project and file, in any order).
RewriteCond ;%{QUERY_STRING} ;p=([^;]*)
RewriteCond ;p=%1;%{QUERY_STRING} ^;p=([^;]*).*;f=([^;]*)
- RewriteRule ^/r/gitweb$ https://git.wikimedia.org/raw/%1/HEAD/%2?
[R=301,L,B]
+ RewriteRule ^/r/gitweb$ https://git.wikimedia.org/raw/%1/HEAD/%2?
[R=301,L,B,NE]
ProxyPass /r/ http://127.0.0.1:8080/r/ retry=0 nocanon
--
To view, visit https://gerrit.wikimedia.org/r/82044
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I949fc00341d08147ad72cdb860526a7dbcd9dc83
Gerrit-PatchSet: 2
Gerrit-Project: operations/puppet
Gerrit-Branch: production
Gerrit-Owner: QChris <[email protected]>
Gerrit-Reviewer: Ottomata <[email protected]>
Gerrit-Reviewer: Spage <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits