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 1f3aa78..90a249f 100644
--- a/docs/tests/FILEFORMAT.md
+++ b/docs/tests/FILEFORMAT.md
@@ -88,6 +88,14 @@
%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 fcfd9f4..8674e76 100644
--- a/tests/data/test1524
+++ b/tests/data/test1524
@@ -4,7 +4,6 @@
HTTP
HTTP PUT
followlocation
-notxml
</keywords>
</info>
#
@@ -12,7 +11,7 @@
<reply>
<data>
HTTP/1.1 303 OK swsclose
-Location: moo.html&testcase=/%TESTNUMBER0002
+Location: moo.html%AMPtestcase=/%TESTNUMBER0002
Connection: close
</data>
@@ -25,7 +24,7 @@
</data2>
<datacheck>
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 @@
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 3d4df02..f9b6dcc 100644
--- a/tests/data/test45
+++ b/tests/data/test45
@@ -4,7 +4,6 @@
HTTP
HTTP GET
followlocation
-notxml
</keywords>
</info>
# Server-side
@@ -13,7 +12,7 @@
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 @@
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 @@
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 7e2b279..4666770 100644
--- a/tests/testutil.pm
+++ b/tests/testutil.pm
@@ -158,6 +158,7 @@
$$thing =~ s/%CR/\r/g; # carriage return aka \r aka 0x0d
$$thing =~ s/%LT/</g;
$$thing =~ s/%GT/>/g;
+ $$thing =~ s/%AMP/&/g;
# include a file
$$thing =~ s/%include ([^%]*)%[\n\r]+/includefile($1, 0)/ge;