]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
tests: add `%AMP` macro, use it in two tests
authorViktor Szakats <commit@vsz.me>
Tue, 2 Dec 2025 04:05:36 +0000 (05:05 +0100)
committerViktor Szakats <commit@vsz.me>
Wed, 3 Dec 2025 19:50:19 +0000 (20:50 +0100)
To allow replacing `&` characters in `tests/data/test*` files for
XML-compliance.

Also:
- document `%GT`, `%LT`
  Follow-up to de49cc89abc917cb4f273ebea8c6fb584d097de2 #19470

Closes #19824

docs/tests/FILEFORMAT.md
tests/data/test1524
tests/data/test45
tests/testutil.pm

index 1f3aa78991b80e90059a684d7029ad4cefb686d1..90a249fac2d28453f4c49f10965adda661c16704 100644 (file)
@@ -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
index fcfd9f4c00010e7f038d05374cc5e1bc2f4ce1f1..8674e7660b0791101a412b52f1f5b10f2253a287 100644 (file)
@@ -4,7 +4,6 @@
 HTTP
 HTTP PUT
 followlocation
-notxml
 </keywords>
 </info>
 #
@@ -12,7 +11,7 @@ notxml
 <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 @@ body
 </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 @@ 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: */*
index 3d4df02f13320060d1a06a3bb13dc109c8628b5e..f9b6dcc6db92f6122bd798f62cf9a471beb5db23 100644 (file)
@@ -4,7 +4,6 @@
 HTTP
 HTTP GET
 followlocation
-notxml
 </keywords>
 </info>
 # 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: */*
index 7e2b279f07a0d2a149b1b63fd21dd402d49ca958..4666770f072dcd7a370b1e9fba9583473945c9f7 100644 (file)
@@ -158,6 +158,7 @@ sub subbase64 {
     $$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;