From 45a327b17dfe268547b4452739c8e4ea4a8138da Mon Sep 17 00:00:00 2001 From: Andy Spencer Date: Sat, 10 Oct 2009 12:57:12 +0000 Subject: [PATCH] improve awk, fix url on andy --- index.cgi | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/index.cgi b/index.cgi index ca53949..aed8c3c 100755 --- a/index.cgi +++ b/index.cgi @@ -25,12 +25,12 @@ function get_modeline { # Extract an uploaded file from standard input # $1 is the boundary delimiter for the file function cut_file { - awk " - /--$1/ {st=1}; - st==2 {print \$0}; - /$1--/ {st=0}; - /^\\r$/ && st==1 {st=2}; - " | head -c -2 | head -c $((128*1024)) + awk -v "bnd=$1" '{ + if ($0 == "--"bnd"\r") { st=1; } + if ($0 == "--"bnd"--\r") { st=0; } + if (st == 2) { print $0; } + if ($0 == "\r" && st == 1) { st=2; } + }' | head -c -2 | head -c $((128*1024)) # Remove trailing ^M's that come with CGI # Limit size to 128K } @@ -199,7 +199,7 @@ EOF } # Main -url="http://$HTTP_HOST/$SCRIPT_URI" +url="http://$HTTP_HOST${REQUEST_URI/\?*}" pathinfo="${REQUEST_URI/*\/}" pathinfo="${pathinfo/\?*}" -- 2.43.2