* [9front] rc-httpd: fold two sed calls into one when computing location
@ 2021-10-29 23:09 igor
0 siblings, 0 replies; only message in thread
From: igor @ 2021-10-29 23:09 UTC (permalink / raw)
To: 9front; +Cc: igor
[-- Attachment #1: Type: text/plain, Size: 1356 bytes --]
At line /rc/bin/rc-httpd/rc-httpd:77 the variable `location` is
computed as follows:
…
location=`{echo $REQUEST_URI | sed 's;\?.*;;'}
location=`{echo $location | sed '
s;[^/]+/\.\./;/;g
s;/\./;/;g
s;//+;/;g
'}
…
Does anyone know why `sed` is used twice to derive the variable
`location`? In other words, why isn't `location` computed using
a single invocation of `sed` like this:
…
location=`{echo $REQUEST_URI | sed '
s;\?.*;;
s;[^/]+/\.\./;/;g
s;/\./;/;g
s;//+;/;g
'}
…
The result should be the same, or am I missing something? The
advantage of this change is one less invocation of `sed` for each http
request.
Here an the git/importable patch:
<snip>
From: Igor Böhm <igor@9lab.org>
Date: Fri, 29 Oct 2021 22:59:06 +0000
Subject: [PATCH] rc-httpd: fold two sed calls into one when computing location
---
diff ee31c7808087c24b268bb5700b6d695c1bae0cd8 76990597f21f5ec3972403e8afbc18dba80ddabe
--- a/rc/bin/rc-httpd/rc-httpd Mon Oct 18 01:35:37 2021
+++ b/rc/bin/rc-httpd/rc-httpd Sat Oct 30 00:59:06 2021
@@ -74,8 +74,8 @@
}
QUERY_STRING=`{echo $REQUEST_URI | sed 's;[^?]*\??;;'}
params=`{echo $QUERY_STRING | sed 's;\+; ;g'}
-location=`{echo $REQUEST_URI | sed 's;\?.*;;'}
-location=`{echo $location | sed '
+location=`{echo $REQUEST_URI | sed '
+ s;\?.*;;
s;[^/]+/\.\./;/;g
s;/\./;/;g
s;//+;/;g
</snap>
Cheers,
Igor
[-- Attachment #2: rc-httpd.patch --]
[-- Type: text/plain, Size: 654 bytes --]
From: Igor Böhm <igor@9lab.org>
Date: Fri, 29 Oct 2021 22:59:06 +0000
Subject: [PATCH] rc-httpd: fold two sed calls into one when computing location
---
diff ee31c7808087c24b268bb5700b6d695c1bae0cd8 76990597f21f5ec3972403e8afbc18dba80ddabe
--- a/rc/bin/rc-httpd/rc-httpd Mon Oct 18 01:35:37 2021
+++ b/rc/bin/rc-httpd/rc-httpd Sat Oct 30 00:59:06 2021
@@ -74,8 +74,8 @@
}
QUERY_STRING=`{echo $REQUEST_URI | sed 's;[^?]*\??;;'}
params=`{echo $QUERY_STRING | sed 's;\+; ;g'}
-location=`{echo $REQUEST_URI | sed 's;\?.*;;'}
-location=`{echo $location | sed '
+location=`{echo $REQUEST_URI | sed '
+ s;\?.*;;
s;[^/]+/\.\./;/;g
s;/\./;/;g
s;//+;/;g
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2021-10-29 23:12 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-29 23:09 [9front] rc-httpd: fold two sed calls into one when computing location igor
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).