From: Viktor Szakats Date: Tue, 2 Dec 2025 04:05:36 +0000 (+0100) Subject: tests: add `%AMP` macro, use it in two tests X-Git-Tag: rc-8_18_0-1~35 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=004f41c186becfd0bae1e5e456ba1842f0db7d9e;p=thirdparty%2Fcurl.git tests: add `%AMP` macro, use it in two tests To allow replacing `&` characters in `tests/data/test*` files for XML-compliance. Also: - document `%GT`, `%LT` Follow-up to de49cc89abc917cb4f273ebea8c6fb584d097de2 #19470 Closes #19824 --- diff --git a/docs/tests/FILEFORMAT.md b/docs/tests/FILEFORMAT.md index 1f3aa78991..90a249fac2 100644 --- a/docs/tests/FILEFORMAT.md +++ b/docs/tests/FILEFORMAT.md @@ -88,6 +88,14 @@ lines: %SP - space %TAB - horizontal tab +## Special characters + +Macros to help keep data files XML-compliant: + + %AMP - Ampersand: `&` + %GT - Greater-than sign: `>` + %LT - Less-than sign: `<` + ## Insert capped epoch days Mostly to test capped cookie expire dates: `%days[NUM]` inserts the number of diff --git a/tests/data/test1524 b/tests/data/test1524 index fcfd9f4c00..8674e7660b 100644 --- a/tests/data/test1524 +++ b/tests/data/test1524 @@ -4,7 +4,6 @@ HTTP HTTP PUT followlocation -notxml # @@ -12,7 +11,7 @@ notxml HTTP/1.1 303 OK swsclose -Location: moo.html&testcase=/%TESTNUMBER0002 +Location: moo.html%AMPtestcase=/%TESTNUMBER0002 Connection: close @@ -25,7 +24,7 @@ body HTTP/1.1 303 OK swsclose -Location: moo.html&testcase=/%TESTNUMBER0002 +Location: moo.html%AMPtestcase=/%TESTNUMBER0002 Connection: close HTTP/1.1 200 OK swsclose @@ -64,7 +63,7 @@ Accept: */* Content-Length: 4 moo -GET /blah/moo.html&testcase=/%TESTNUMBER0002 HTTP/1.1 +GET /blah/moo.html%AMPtestcase=/%TESTNUMBER0002 HTTP/1.1 Host: %HOSTIP:%HTTPPORT User-Agent: curl/%VERSION Accept: */* diff --git a/tests/data/test45 b/tests/data/test45 index 3d4df02f13..f9b6dcc6db 100644 --- a/tests/data/test45 +++ b/tests/data/test45 @@ -4,7 +4,6 @@ HTTP HTTP GET followlocation -notxml # Server-side @@ -13,7 +12,7 @@ notxml HTTP/1.1 301 This is a weirdo text message swsclose Date: Tue, 09 Nov 2010 14:49:00 GMT Server: test-server/fake -Location: data.cgi?moo=http://&/%TESTNUMBER0002 +Location: data.cgi?moo=http://%AMP/%TESTNUMBER0002 Connection: close This server reply is for testing a simple Location: following @@ -32,7 +31,7 @@ If this is received, the location following worked HTTP/1.1 301 This is a weirdo text message swsclose Date: Tue, 09 Nov 2010 14:49:00 GMT Server: test-server/fake -Location: data.cgi?moo=http://&/%TESTNUMBER0002 +Location: data.cgi?moo=http://%AMP/%TESTNUMBER0002 Connection: close HTTP/1.1 200 Followed here fine swsclose @@ -66,7 +65,7 @@ Host: %HOSTIP:%HTTPPORT User-Agent: curl/%VERSION Accept: */* -GET /want/data.cgi?moo=http://&/%TESTNUMBER0002 HTTP/1.1 +GET /want/data.cgi?moo=http://%AMP/%TESTNUMBER0002 HTTP/1.1 Host: %HOSTIP:%HTTPPORT User-Agent: curl/%VERSION Accept: */* diff --git a/tests/testutil.pm b/tests/testutil.pm index 7e2b279f07..4666770f07 100644 --- a/tests/testutil.pm +++ b/tests/testutil.pm @@ -158,6 +158,7 @@ sub subbase64 { $$thing =~ s/%CR/\r/g; # carriage return aka \r aka 0x0d $$thing =~ s/%LT//g; + $$thing =~ s/%AMP/&/g; # include a file $$thing =~ s/%include ([^%]*)%[\n\r]+/includefile($1, 0)/ge;