unescape is probably a better name

parent 0e666334
......@@ -510,7 +510,7 @@ vmod_object(VRT_CTX, VCL_STRANDS s)
} while(0)
VCL_STRING
vmod_unquote(VRT_CTX, VCL_STRING p, VCL_STRING fallback)
vmod_unescape(VRT_CTX, VCL_STRING p, VCL_STRING fallback)
{
struct vsb vsb[1];
const char *err = NULL;
......@@ -520,19 +520,19 @@ vmod_unquote(VRT_CTX, VCL_STRING p, VCL_STRING fallback)
CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
if (*p != '"' || p[strlen(p) - 1] != '"') {
fail(ctx, fallback, "j.unquote() argument missing quotes");
fail(ctx, fallback, "j.unescape() argument missing quotes");
return (fallback);
}
p++;
WS_VSB_new(vsb, ctx->ws);
if (vsbjunquot(vsb, p, &err) && err != NULL) {
fail(ctx, fallback, "j.unquote() error at: ...%.10s", err);
fail(ctx, fallback, "j.unescape() error at: ...%.10s", err);
return (fallback);
}
r = WS_VSB_finish(vsb, ctx->ws, NULL);
if (r == NULL) {
VRT_fail(ctx, "j.unquote(): out of workspace");
VRT_fail(ctx, "j.unescape(): out of workspace");
return (NULL);
}
l = strlen(r);
......
......@@ -39,7 +39,7 @@ SYNOPSIS
STRING object(STRING)
STRING unquote(STRING, STRING fallback)
STRING unescape(STRING, STRING fallback)
INTRODUCTION
......@@ -258,7 +258,7 @@ The two exceptions are:
the `Höhrmann`_ decoder, which fails for invalid UTF-8, but only
conducts minimal checks on Unicode points.
* `j.unquote()`_ fails if the input is not a valid JSON string or if
* `j.unescape()`_ fails if the input is not a valid JSON string or if
invalid UTF-8 would be produced.
Other character encodings
......@@ -444,10 +444,10 @@ ALIAS obj()
Deprecated alias for ``object()``.
.. _j.unquote():
.. _j.unescape():
STRING unquote(STRING, STRING fallback=0)
-----------------------------------------
STRING unescape(STRING, STRING fallback=0)
------------------------------------------
Utility function to decode JSON strings into UTF-8.
......
......@@ -244,7 +244,7 @@ The two exceptions are:
the `Höhrmann`_ decoder, which fails for invalid UTF-8, but only
conducts minimal checks on Unicode points.
* `j.unquote()`_ fails if the input is not a valid JSON string or if
* `j.unescape()`_ fails if the input is not a valid JSON string or if
invalid UTF-8 would be produced.
Other character encodings
......@@ -381,7 +381,7 @@ concatenation argument (strands) as key/value pairs.
$Alias obj object
$Function STRING unquote(STRING, STRING fallback=0)
$Function STRING unescape(STRING, STRING fallback=0)
Utility function to decode JSON strings into UTF-8.
......
......@@ -109,8 +109,8 @@ varnish v1 -vcl {
);
set resp.http.o4 = j.object(j.string("A") + j.object(j.nil()));
set resp.http.unok = j.unquote({""abc""});
set resp.http.unno = j.unquote("", j.null());
set resp.http.unok = j.unescape({""abc""});
set resp.http.unno = j.unescape("", j.null());
set resp.body = "";
return (deliver);
......
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