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
60c5271f
Unverified
Commit
60c5271f
authored
Sep 08, 2023
by
Nils Goroll
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
unescape is probably a better name
parent
0e666334
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
13 additions
and
13 deletions
+13
-13
vmod_j.c
src/vmod_j.c
+4
-4
vmod_j.man.rst
src/vmod_j.man.rst
+5
-5
vmod_j.vcc
src/vmod_j.vcc
+2
-2
vmod_j.vtc
src/vtc/vmod_j.vtc
+2
-2
No files found.
src/vmod_j.c
View file @
60c5271f
...
@@ -510,7 +510,7 @@ vmod_object(VRT_CTX, VCL_STRANDS s)
...
@@ -510,7 +510,7 @@ vmod_object(VRT_CTX, VCL_STRANDS s)
} while(0)
} while(0)
VCL_STRING
VCL_STRING
vmod_un
quot
e
(
VRT_CTX
,
VCL_STRING
p
,
VCL_STRING
fallback
)
vmod_un
escap
e
(
VRT_CTX
,
VCL_STRING
p
,
VCL_STRING
fallback
)
{
{
struct
vsb
vsb
[
1
];
struct
vsb
vsb
[
1
];
const
char
*
err
=
NULL
;
const
char
*
err
=
NULL
;
...
@@ -520,19 +520,19 @@ vmod_unquote(VRT_CTX, VCL_STRING p, VCL_STRING fallback)
...
@@ -520,19 +520,19 @@ vmod_unquote(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
!=
'"'
||
p
[
strlen
(
p
)
-
1
]
!=
'"'
)
{
fail
(
ctx
,
fallback
,
"j.un
quot
e() argument missing quotes"
);
fail
(
ctx
,
fallback
,
"j.un
escap
e() argument missing quotes"
);
return
(
fallback
);
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
)
{
fail
(
ctx
,
fallback
,
"j.un
quot
e() error at: ...%.10s"
,
err
);
fail
(
ctx
,
fallback
,
"j.un
escap
e() error at: ...%.10s"
,
err
);
return
(
fallback
);
return
(
fallback
);
}
}
r
=
WS_VSB_finish
(
vsb
,
ctx
->
ws
,
NULL
);
r
=
WS_VSB_finish
(
vsb
,
ctx
->
ws
,
NULL
);
if
(
r
==
NULL
)
{
if
(
r
==
NULL
)
{
VRT_fail
(
ctx
,
"j.un
quot
e(): out of workspace"
);
VRT_fail
(
ctx
,
"j.un
escap
e(): out of workspace"
);
return
(
NULL
);
return
(
NULL
);
}
}
l
=
strlen
(
r
);
l
=
strlen
(
r
);
...
...
src/vmod_j.man.rst
View file @
60c5271f
...
@@ -39,7 +39,7 @@ SYNOPSIS
...
@@ -39,7 +39,7 @@ SYNOPSIS
STRING object(STRING)
STRING object(STRING)
STRING un
quot
e(STRING, STRING fallback)
STRING un
escap
e(STRING, STRING fallback)
INTRODUCTION
INTRODUCTION
...
@@ -258,7 +258,7 @@ The two exceptions are:
...
@@ -258,7 +258,7 @@ The two exceptions are:
the `Höhrmann`_ decoder, which fails for invalid UTF-8, but only
the `Höhrmann`_ decoder, which fails for invalid UTF-8, but only
conducts minimal checks on Unicode points.
conducts minimal checks on Unicode points.
* `j.un
quot
e()`_ fails if the input is not a valid JSON string or if
* `j.un
escap
e()`_ fails if the input is not a valid JSON string or if
invalid UTF-8 would be produced.
invalid UTF-8 would be produced.
Other character encodings
Other character encodings
...
@@ -444,10 +444,10 @@ ALIAS obj()
...
@@ -444,10 +444,10 @@ ALIAS obj()
Deprecated alias for ``object()``.
Deprecated alias for ``object()``.
.. _j.un
quot
e():
.. _j.un
escap
e():
STRING un
quot
e(STRING, STRING fallback=0)
STRING un
escap
e(STRING, STRING fallback=0)
-----------------------------------------
-----------------------------------------
-
Utility function to decode JSON strings into UTF-8.
Utility function to decode JSON strings into UTF-8.
...
...
src/vmod_j.vcc
View file @
60c5271f
...
@@ -244,7 +244,7 @@ The two exceptions are:
...
@@ -244,7 +244,7 @@ The two exceptions are:
the `Höhrmann`_ decoder, which fails for invalid UTF-8, but only
the `Höhrmann`_ decoder, which fails for invalid UTF-8, but only
conducts minimal checks on Unicode points.
conducts minimal checks on Unicode points.
* `j.un
quot
e()`_ fails if the input is not a valid JSON string or if
* `j.un
escap
e()`_ fails if the input is not a valid JSON string or if
invalid UTF-8 would be produced.
invalid UTF-8 would be produced.
Other character encodings
Other character encodings
...
@@ -381,7 +381,7 @@ concatenation argument (strands) as key/value pairs.
...
@@ -381,7 +381,7 @@ concatenation argument (strands) as key/value pairs.
$Alias obj object
$Alias obj object
$Function STRING un
quot
e(STRING, STRING fallback=0)
$Function STRING un
escap
e(STRING, STRING fallback=0)
Utility function to decode JSON strings into UTF-8.
Utility function to decode JSON strings into UTF-8.
...
...
src/vtc/vmod_j.vtc
View file @
60c5271f
...
@@ -109,8 +109,8 @@ varnish v1 -vcl {
...
@@ -109,8 +109,8 @@ 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.un
quot
e({""abc""});
set resp.http.unok = j.un
escap
e({""abc""});
set resp.http.unno = j.un
quot
e("", j.null());
set resp.http.unno = j.un
escap
e("", 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