mirror of
https://github.com/moparisthebest/curl
synced 2024-12-24 09:08:49 -05:00
runtests: allow generating a binary sequence from hex
This commit is contained in:
parent
01327600e3
commit
2dd53e82f1
@ -40,6 +40,19 @@ server's port number (in ASCII) followed by a space and the hexadecimal byte
|
|||||||
|
|
||||||
%b64[%HTTPPORT %9a]b64%
|
%b64[%HTTPPORT %9a]b64%
|
||||||
|
|
||||||
|
## Hexadecimal decoding
|
||||||
|
|
||||||
|
In the preprocess stage, a special instruction can be used to have runtests.pl
|
||||||
|
generate a sequence of binary bytes.
|
||||||
|
|
||||||
|
To insert a sequence of bytes from a hex encoded string, use this syntax:
|
||||||
|
|
||||||
|
%hex[ %XX-encoded data to decode ]hex%
|
||||||
|
|
||||||
|
For example, to insert the binary octets 0, 1 and 255 into the test file:
|
||||||
|
|
||||||
|
%hex[ %00%01%FF ]hex%
|
||||||
|
|
||||||
# Variables
|
# Variables
|
||||||
|
|
||||||
When the test is preprocessed, a range of "variables" in the test file will be
|
When the test is preprocessed, a range of "variables" in the test file will be
|
||||||
|
@ -3304,6 +3304,13 @@ sub subBase64 {
|
|||||||
# put the result into there
|
# put the result into there
|
||||||
$$thing =~ s/%%B64%%/$enc/;
|
$$thing =~ s/%%B64%%/$enc/;
|
||||||
}
|
}
|
||||||
|
# hex decode
|
||||||
|
if($$thing =~ s/%hex\[(.*)\]hex%/%%HEX%%/i) {
|
||||||
|
# decode %NN characters
|
||||||
|
my $d = $1;
|
||||||
|
$d =~ s/%([0-9A-Fa-f]{2})/chr(hex($1))/eg;
|
||||||
|
$$thing =~ s/%%HEX%%/$d/;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sub fixarray {
|
sub fixarray {
|
||||||
|
Loading…
Reference in New Issue
Block a user