Commit 99e3618a authored by Geoff Simmons's avatar Geoff Simmons

distinguish between the decoding HEX and the encodings HEXUC and HEXLC

parent ef22cf37
......@@ -108,6 +108,7 @@ my @vals = (qw(
BASE64URL
BASE64URLNOPAD
HEX
HEXUC
HEXLC));
unless ($#ARGV == 1) {
......
......@@ -120,6 +120,7 @@ hex_encode(const enum encoding enc, char *restrict const buf,
const char *alphabet = hex_alphabet[0];
AN(buf);
assert(enc == HEXUC || enc == HEXLC);
if (in == NULL || inlen == 0)
return 0;
if (maxlen < hex_encode_l(inlen))
......
......@@ -17,7 +17,7 @@ varnish v1 -vcl+backend {
"The quick brown fox jumps over the lazy dog"));
set resp.http.hexuc =
convert.encode(HEX, convert.decode(IDENTITY,
convert.encode(HEXUC, convert.decode(IDENTITY,
"The quick brown fox jumps over the lazy dog"));
set resp.http.decuc =
......@@ -60,7 +60,7 @@ varnish v1 -vcl+backend {
req.url);
set resp.http.hexucxcode =
convert.transcode(IDENTITY, HEX, req.url +
convert.transcode(IDENTITY, HEXUC, req.url +
"Hel" + "lo " + "" + "world" +
req.url);
}
......@@ -92,7 +92,7 @@ varnish v1 -vcl+backend {
sub vcl_synth {
set req.http.foo = "123";
set resp.http.badhex = convert.encode(HEX,
set resp.http.badhex = convert.encode(HEXUC,
convert.decode(HEX, "g" + req.http.foo));
}
}
......
......@@ -16,7 +16,7 @@ varnish v1 -vcl+backend {
= convert.transcode(IDENTITY, IDENTITY, "Hello world");
set resp.http.hexuc2hexuc
= convert.transcode(HEX, HEX, "0123456789ABCDEF");
= convert.transcode(HEX, HEXUC, "0123456789ABCDEF");
set resp.http.hexlc2hexlc
= convert.transcode(HEX, HEXLC, "0123456789abcdef");
......@@ -25,10 +25,10 @@ varnish v1 -vcl+backend {
= convert.transcode(HEX, HEXLC, "0123456789ABCDEF");
set resp.http.hexlc2hexuc
= convert.transcode(HEX, HEX, "0123456789abcdef");
= convert.transcode(HEX, HEXUC, "0123456789abcdef");
set resp.http.hexmix2hexuc
= convert.transcode(HEX, HEX, "0123456789ABCdef");
= convert.transcode(HEX, HEXUC, "0123456789ABCdef");
set resp.http.hexmix2hexlc
= convert.transcode(HEX, HEXLC, "0123456789abcDEF");
......@@ -56,7 +56,6 @@ varnish v1 -vcl+backend {
"+/+/" + req.http.foo);
set resp.http.badpad = convert.transcode(BASE64URLNOPAD, IDENTITY,
"TWFu" + req.http.foo);
set resp.http.badhex2hex = convert.transcode(HEX, HEX, "abcdefg");
set resp.http.bad64264 = convert.transcode(BASE64, BASE64,
"_-_-" + req.http.foo);
set resp.http.badurl2url = convert.transcode(BASE64URL, BASE64URL,
......@@ -74,14 +73,13 @@ client c1 {
expect resp.http.hexuc2hexuc == "0123456789ABCDEF"
expect resp.http.hexlc2hexlc == "0123456789abcdef"
expect resp.http.hexuc2hexlc == "0123456789abcdef"
# expect resp.http.hexlc2hexuc == "0123456789ABCDEF"
# expect resp.http.hexmix2hexuc == "0123456789ABCDEF"
expect resp.http.hexlc2hexuc == "0123456789ABCDEF"
expect resp.http.hexmix2hexuc == "0123456789ABCDEF"
expect resp.http.hexmix2hexlc == "0123456789abcdef"
expect resp.http.b642b64 == "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
expect resp.http.b64url2b64url == "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"
expect resp.http.b64urlnopad2b64urlnopad == "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"
expect resp.http.badhex == ""
expect resp.http.badhex2hex == ""
expect resp.http.bad64 == ""
expect resp.http.bad64264 == ""
expect resp.http.badurl == ""
......@@ -101,8 +99,6 @@ logexpect l1 -v v1 -d 1 -g vxid -q "VCL_Error" {
expect * = VCL_Error "^vmod convert error: cannot decode, illegal encoding beginning with \"\+/\+/\"$"
#"
expect * = VCL_Error "^vmod convert error: cannot decode, illegal encoding beginning with \"TWFu\"$"
#"
expect * = VCL_Error "^vmod convert error: cannot decode, illegal encoding beginning with \"abcdefg\"$"
#"
expect * = VCL_Error "^vmod convert error: cannot decode, illegal encoding beginning with \"_-_-\"$"
#"
......
......@@ -94,7 +94,6 @@ decode_l_va(enum encoding dec, const char * const p, va_list ap)
case BASE64URLNOPAD:
return base64_decode_l(len);
case HEX:
case HEXLC:
return hex_decode_l(len);
default:
WRONG("Illegal decoding");
......@@ -131,7 +130,7 @@ encode(const enum encoding enc, char *restrict const buf, const size_t maxlen,
case BASE64URL:
case BASE64URLNOPAD:
return base64_encode(enc, buf, maxlen, in, inlen);
case HEX:
case HEXUC:
case HEXLC:
return hex_encode(enc, buf, maxlen, in, inlen);
default:
......
......@@ -20,7 +20,7 @@ $Method BLOB .get()
$Function BLOB decode(ENUM { IDENTITY, BASE64, BASE64URL, BASE64URLNOPAD, HEX}, STRING_LIST)
XXX DOC
$Function STRING encode(ENUM { IDENTITY, BASE64, BASE64URL, BASE64URLNOPAD, HEX, HEXLC}, BLOB)
$Function STRING encode(ENUM { IDENTITY, BASE64, BASE64URL, BASE64URLNOPAD, HEXUC, HEXLC}, BLOB)
XXX DOC
$Function STRING transcode(ENUM { IDENTITY, BASE64, BASE64URL, BASE64URLNOPAD, HEX}, ENUM { IDENTITY, BASE64, BASE64URL, BASE64URLNOPAD, HEX, HEXLC}, STRING_LIST)
$Function STRING transcode(ENUM { IDENTITY, BASE64, BASE64URL, BASE64URLNOPAD, HEX}, ENUM { IDENTITY, BASE64, BASE64URL, BASE64URLNOPAD, HEXUC, HEXLC}, STRING_LIST)
XXX DOC
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment