From 688d3f6b5c2e2911e1af8c002507921dfc368596 Mon Sep 17 00:00:00 2001 From: Taylan Ulrich B Date: Thu, 25 Aug 2011 22:56:18 +0200 Subject: various formfiller fixes --- examples/data/scripts/formfiller.sh | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) (limited to 'examples/data/scripts/formfiller.sh') diff --git a/examples/data/scripts/formfiller.sh b/examples/data/scripts/formfiller.sh index 394bfbd..52d6ec6 100755 --- a/examples/data/scripts/formfiller.sh +++ b/examples/data/scripts/formfiller.sh @@ -63,6 +63,9 @@ ParseFields () awk '/^%/ { sub ( /%/, "" ) + gsub ( /\\/, "\\\\\\\\" ) + gsub ( /@/, "\\@" ) + gsub ( /"/, "\\\"" ) split( $0, parts, /\(|\)|\{|\}/ ) @@ -73,15 +76,24 @@ ParseFields () printf( "js uzbl.formfiller.insert(\"%s\",\"%s\",\"%s\",%s);\n", parts[1], parts[2], parts[3], field ) - else if ( parts[2] ~ /^textarea$/ ) { + else if ( parts[2] == "textarea" ) { field = "" while (getline) { if ( /^%/ ) break sub ( /^\\/, "" ) + # JavaScript escape + gsub ( /\\/, "\\\\\\\\" ) gsub ( /"/, "\\\"" ) - gsub ( /\\/, "\\\\" ) - field = field $0 "\\\\n" + # To support the possibility of the last line of the textarea + # not being terminated by a newline, we add the newline here. + # The "if (field)" is so that this does not happen in the first + # iteration. + if (field) field = field "\\n" + field = field $0 } + # Uzbl escape + gsub ( /\\/, "\\\\\\\\", field ) + gsub ( /@/, "\\@", field ) printf( "js uzbl.formfiller.insert(\"%s\",\"%s\",\"%s\",0);\n", parts[1], parts[2], field ) } @@ -120,7 +132,6 @@ Load () ParseProfile $option < "$file" \ | ParseFields \ - | sed 's/@/\\@/g' \ > "$UZBL_FIFO" } @@ -136,7 +147,6 @@ Once () test -e "$tmpfile" && ParseFields < "$tmpfile" \ - | sed 's/@/\\@/g' \ > "$UZBL_FIFO" } -- cgit v1.2.3