shithub: werc

Download patch

ref: 18734074da2a1e334bd66c161695993c01708c1c
parent: 2df7b66ecb21bd1dfee68e1497c6f5aa31da04ec
author: uriel <uriel@vm41.cat-v.org>
date: Tue Jun 9 22:58:36 EDT 2009

Urldecode '_' (ie., %5F) in request paths to make stackoverflow.com links happy.

--- a/bin/werc.rc
+++ b/bin/werc.rc
@@ -41,7 +41,9 @@
     current_date_time=`{date}
 
     # Note: $REQUEST_URI is not officially in CGI 1.1, but seems to be de-facto
-    req_path=`{echo -n $REQUEST_URI | sed 's/\?.*//; s!//+!/!g; s/'^$forbidden_uri_chars^'//g; s/\.\.*/./g; 1q'}
+    # Note: We only urldecode %5F->'_' because some sites (stackoverflow.com?) urlencode it in their links,
+    # perhaps we should completel urldecode the whole url.
+    req_path=`{echo -n $REQUEST_URI | sed 's/\?.*//; s!//+!/!g; s/%5[Ff]/_/g; s/'^$forbidden_uri_chars^'//g; s/\.\.*/./g; 1q'}
     req_url=$base_url^$req_path
     local_path=$sitedir$req_path
     ifs='/' { args=`{echo -n $req_path} }