Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
libvmod-j
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
uplex-varnish
libvmod-j
Commits
4f503911
Unverified
Commit
4f503911
authored
Sep 08, 2023
by
Nils Goroll
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix unescape error detection and make it tolerate quotes
parent
60c5271f
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
13 additions
and
9 deletions
+13
-9
vmod_j.c
src/vmod_j.c
+6
-8
vmod_j.man.rst
src/vmod_j.man.rst
+3
-0
vmod_j.vcc
src/vmod_j.vcc
+3
-0
vmod_j.vtc
src/vtc/vmod_j.vtc
+1
-1
No files found.
src/vmod_j.c
View file @
4f503911
...
@@ -519,14 +519,12 @@ vmod_unescape(VRT_CTX, VCL_STRING p, VCL_STRING fallback)
...
@@ -519,14 +519,12 @@ vmod_unescape(VRT_CTX, VCL_STRING p, VCL_STRING fallback)
CHECK_OBJ_NOTNULL
(
ctx
,
VRT_CTX_MAGIC
);
CHECK_OBJ_NOTNULL
(
ctx
,
VRT_CTX_MAGIC
);
if
(
*
p
!=
'"'
||
p
[
strlen
(
p
)
-
1
]
!=
'"'
)
{
if
(
*
p
==
'"'
)
fail
(
ctx
,
fallback
,
"j.unescape() argument missing quotes"
);
return
(
fallback
);
}
p
++
;
p
++
;
WS_VSB_new
(
vsb
,
ctx
->
ws
);
WS_VSB_new
(
vsb
,
ctx
->
ws
);
if
(
vsbjunquot
(
vsb
,
p
,
&
err
)
&&
err
!=
NULL
)
{
if
(
!
vsbjunquot
(
vsb
,
p
,
&
err
)
&&
err
!=
NULL
)
{
WS_Release
(
ctx
->
ws
,
0
);
fail
(
ctx
,
fallback
,
"j.unescape() error at: ...%.10s"
,
err
);
fail
(
ctx
,
fallback
,
"j.unescape() error at: ...%.10s"
,
err
);
return
(
fallback
);
return
(
fallback
);
}
}
...
@@ -540,7 +538,7 @@ vmod_unescape(VRT_CTX, VCL_STRING p, VCL_STRING fallback)
...
@@ -540,7 +538,7 @@ vmod_unescape(VRT_CTX, VCL_STRING p, VCL_STRING fallback)
return
(
r
);
return
(
r
);
l
--
;
l
--
;
assert
(
r
[
l
]
==
'"'
);
if
(
r
[
l
]
==
'"'
)
r
[
l
]
=
'\0'
;
r
[
l
]
=
'\0'
;
return
(
r
);
return
(
r
);
}
}
src/vmod_j.man.rst
View file @
4f503911
...
@@ -451,6 +451,9 @@ STRING unescape(STRING, STRING fallback=0)
...
@@ -451,6 +451,9 @@ STRING unescape(STRING, STRING fallback=0)
Utility function to decode JSON strings into UTF-8.
Utility function to decode JSON strings into UTF-8.
The string may contain surrounding quotes, which are silently removed,
even if only left *or* right quotes are present.
If decoding fails and *fallback* is provided, the error is logged with
If decoding fails and *fallback* is provided, the error is logged with
tag ``Error`` and *fallback* is returned. Otherwise, the VCL is failed.
tag ``Error`` and *fallback* is returned. Otherwise, the VCL is failed.
...
...
src/vmod_j.vcc
View file @
4f503911
...
@@ -385,6 +385,9 @@ $Function STRING unescape(STRING, STRING fallback=0)
...
@@ -385,6 +385,9 @@ $Function STRING unescape(STRING, STRING fallback=0)
Utility function to decode JSON strings into UTF-8.
Utility function to decode JSON strings into UTF-8.
The string may contain surrounding quotes, which are silently removed,
even if only left *or* right quotes are present.
If decoding fails and *fallback* is provided, the error is logged with
If decoding fails and *fallback* is provided, the error is logged with
tag ``Error`` and *fallback* is returned. Otherwise, the VCL is failed.
tag ``Error`` and *fallback* is returned. Otherwise, the VCL is failed.
...
...
src/vtc/vmod_j.vtc
View file @
4f503911
...
@@ -110,7 +110,7 @@ varnish v1 -vcl {
...
@@ -110,7 +110,7 @@ varnish v1 -vcl {
set resp.http.o4 = j.object(j.string("A") + j.object(j.nil()));
set resp.http.o4 = j.object(j.string("A") + j.object(j.nil()));
set resp.http.unok = j.unescape({""abc""});
set resp.http.unok = j.unescape({""abc""});
set resp.http.unno = j.unescape("", j.null());
set resp.http.unno = j.unescape("
\udc00
", j.null());
set resp.body = "";
set resp.body = "";
return (deliver);
return (deliver);
...
...
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