Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
varnish-cache
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
varnishcache
varnish-cache
Commits
df853281
Unverified
Commit
df853281
authored
Mar 25, 2021
by
Nils Goroll
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add BASE64CF codec
Each their own variant, *sigh*
parent
bd3d4146
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
69 additions
and
9 deletions
+69
-9
blob_b00004.vtc
vmod/tests/blob_b00004.vtc
+10
-0
vmod_blob.c
vmod/vmod_blob.c
+4
-0
vmod_blob.vcc
vmod/vmod_blob.vcc
+15
-9
vmod_blob_base64.c
vmod/vmod_blob_base64.c
+39
-0
vmod_blob_tbl_encodings.h
vmod/vmod_blob_tbl_encodings.h
+1
-0
No files found.
vmod/tests/blob_b00004.vtc
View file @
df853281
...
...
@@ -96,6 +96,14 @@ varnish v1 -vcl {
set resp.http.b64urlnopadxcode =
blob.transcode(IDENTITY, BASE64URLNOPAD,
encoded=req.url + "Hello world" + req.url);
set resp.http.b64cfxcodeout =
blob.transcode(BASE64, BASE64CF,
encoded="+/Y=");
set resp.http.b64cfxcodein =
blob.transcode(BASE64CF, BASE64,
encoded="-~Y_");
}
} -start
...
...
@@ -122,6 +130,8 @@ client c1 {
expect resp.http.b64xcode == "L0hlbGxvIHdvcmxkLw=="
expect resp.http.b64urlxcode == "L0hlbGxvIHdvcmxkLw=="
expect resp.http.b64urlnopadxcode == "L0hlbGxvIHdvcmxkLw"
expect resp.http.b64cfxcodeout == "-~Y_"
expect resp.http.b64cfxcodein == "+/Y="
} -run
varnish v1 -vcl {
...
...
vmod/vmod_blob.c
View file @
df853281
...
...
@@ -76,6 +76,10 @@ static const struct vmod_blob_fptr {
B64_FUNCS
,
.
encode_l
=
base64nopad_encode_l
},
[
BASE64CF
]
=
{
B64_FUNCS
,
.
encode_l
=
base64_encode_l
},
[
HEX
]
=
{
.
decode_l
=
hex_decode_l
,
.
decode
=
hex_decode
,
...
...
vmod/vmod_blob.vcc
View file @
df853281
...
...
@@ -70,6 +70,7 @@ ENUM values for an encoding scheme can be one of:
* ``BASE64``
* ``BASE64URL``
* ``BASE64URLNOPAD``
* ``BASE64CF``
* ``HEX``
* ``URL``
...
...
@@ -141,6 +142,11 @@ The ``BASE64URLNOPAD`` encoding uses the same alphabet as
``BASE6URL``, but leaves out the padding. Thus the length of an
encoding with this scheme is not necessarily a multiple of four.
The ``BASE64CF` is similar to ``BASE64URL``, with the following
changes to ``BASE64``: ``+`` replaced with ``-``, ``/`` replaced with
``~`` and ``_`` as the padding character. It is used by a certain CDN
provider who also inspired the name.
The *case* ENUM MUST be set to ``DEFAULT`` for for all of the
``BASE64*`` encodings.
...
...
@@ -176,8 +182,8 @@ The ``URL`` encoding implements "percent encoding" as per RFC3986. The
affect alphabetic characters that are not percent-encoded.
$Function BLOB decode(ENUM {IDENTITY, BASE64, BASE64URL, BASE64URLNOPAD,
HEX, URL} decoding="IDENTITY", INT length=0
,
STRANDS encoded)
BASE64CF, HEX, URL} decoding="IDENTITY"
,
INT length=0,
STRANDS encoded)
Returns the BLOB derived from the string *encoded* according to the
scheme specified by *decoding*.
...
...
@@ -201,7 +207,7 @@ Example::
$Function STRING encode(ENUM {IDENTITY, BASE64, BASE64URL, BASE64URLNOPAD,
HEX, URL} encoding="IDENTITY",
BASE64CF,
HEX, URL} encoding="IDENTITY",
ENUM {LOWER, UPPER, DEFAULT} case="DEFAULT", BLOB blob)
Returns a string representation of the BLOB *blob* as specified by
...
...
@@ -230,9 +236,9 @@ Example::
= blob.encode(blob=blob.decode(encoded="foo"));
$Function STRING transcode(ENUM {IDENTITY, BASE64, BASE64URL, BASE64URLNOPAD,
HEX, URL} decoding="IDENTITY",
BASE64CF,
HEX, URL} decoding="IDENTITY",
ENUM {IDENTITY, BASE64, BASE64URL, BASE64URLNOPAD,
HEX, URL} encoding="IDENTITY",
BASE64CF,
HEX, URL} encoding="IDENTITY",
ENUM {LOWER, UPPER, DEFAULT} case="DEFAULT",
INT length=0, STRANDS encoded)
...
...
@@ -303,8 +309,8 @@ default value of *offset* is ``0B``.
``offset + length`` requires more bytes than are available in the
BLOB.
$Object blob(ENUM {IDENTITY, BASE64, BASE64URL, BASE64URLNOPAD,
HEX
,
URL} decoding="IDENTITY",
$Object blob(ENUM {IDENTITY, BASE64, BASE64URL, BASE64URLNOPAD,
BASE64CF
,
HEX,
URL} decoding="IDENTITY",
STRANDS encoded)
Creates an object that contains the BLOB derived from the string
...
...
@@ -335,8 +341,8 @@ Example::
set resp.http.The-Stringblob =
blob.encode(blob=stringblob.get());
$Method STRING .encode(ENUM {IDENTITY, BASE64, BASE64URL, BASE64URLNOPAD,
HEX,
URL} encoding="IDENTITY",
$Method STRING .encode(ENUM {IDENTITY, BASE64, BASE64URL, BASE64URLNOPAD,
BASE64CF, HEX,
URL} encoding="IDENTITY",
ENUM {LOWER, UPPER, DEFAULT} case="DEFAULT")
Returns an encoding of BLOB created by the constructor, according to
...
...
vmod/vmod_blob_base64.c
View file @
df853281
...
...
@@ -158,6 +158,45 @@ static const struct b64_alphabet {
},
0
},
[
BASE64CF
]
=
{
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdef"
"ghijklmnopqrstuvwxyz0123456789-~"
,
{
ILL
,
ILL
,
ILL
,
ILL
,
ILL
,
ILL
,
ILL
,
ILL
,
ILL
,
ILL
,
ILL
,
ILL
,
ILL
,
ILL
,
ILL
,
ILL
,
ILL
,
ILL
,
ILL
,
ILL
,
ILL
,
ILL
,
ILL
,
ILL
,
ILL
,
ILL
,
ILL
,
ILL
,
ILL
,
ILL
,
ILL
,
ILL
,
ILL
,
ILL
,
ILL
,
ILL
,
ILL
,
ILL
,
ILL
,
ILL
,
ILL
,
ILL
,
IL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
,
ILL
,
ILL
,
ILL
,
ILL
,
ILL
,
ILL
,
ILL
,
ILL
,
ILL
,
ILL
,
ILL
,
ILL
,
ILL
,
ILL
,
ILL
,
ILL
,
ILL
,
ILL
,
ILL
,
ILL
,
ILL
,
ILL
,
ILL
,
ILL
,
ILL
,
ILL
,
ILL
,
ILL
,
ILL
,
ILL
,
ILL
,
ILL
,
ILL
,
ILL
,
ILL
,
ILL
,
ILL
,
},
'_'
}
};
#define base64_l(l) (((l) << 2) / 3)
...
...
vmod/vmod_blob_tbl_encodings.h
View file @
df853281
...
...
@@ -6,6 +6,7 @@
VMODENUM
(
BASE64
)
VMODENUM
(
BASE64URL
)
VMODENUM
(
BASE64URLNOPAD
)
VMODENUM
(
BASE64CF
)
VMODENUM
(
HEX
)
VMODENUM
(
IDENTITY
)
VMODENUM
(
URL
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment