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
b469b6e7
Commit
b469b6e7
authored
Mar 09, 2016
by
Poul-Henning Kamp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Teach VSB_quote() to hexdump. All zero bits will be elided to "0x0...0"
parent
655aadea
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
3 deletions
+23
-3
vsb.h
include/vsb.h
+2
-1
vsb.c
lib/libvarnish/vsb.c
+21
-2
No files found.
include/vsb.h
View file @
b469b6e7
...
...
@@ -78,7 +78,8 @@ void VSB_delete(struct vsb *);
void
VSB_destroy
(
struct
vsb
**
);
#define VSB_QUOTE_NONL 1
#define VSB_QUOTE_JSON 2
void
VSB_quote
(
struct
vsb
*
s
,
const
char
*
p
,
int
len
,
int
how
);
#define VSB_QUOTE_HEX 4
void
VSB_quote
(
struct
vsb
*
,
const
void
*
,
int
len
,
int
how
);
void
VSB_indent
(
struct
vsb
*
,
int
);
#ifdef __cplusplus
};
...
...
lib/libvarnish/vsb.c
View file @
b469b6e7
...
...
@@ -500,13 +500,32 @@ VSB_destroy(struct vsb **s)
* Quote a string
*/
void
VSB_quote
(
struct
vsb
*
s
,
const
char
*
p
,
int
len
,
int
how
)
VSB_quote
(
struct
vsb
*
s
,
const
void
*
v
,
int
len
,
int
how
)
{
const
char
*
p
;
const
char
*
q
;
int
quote
=
0
;
const
unsigned
char
*
u
,
*
w
;
assert
(
v
!=
NULL
);
if
(
len
==
-
1
)
len
=
strlen
(
p
);
len
=
strlen
(
v
);
if
(
how
&
VSB_QUOTE_HEX
)
{
u
=
v
;
for
(
w
=
u
;
w
<
u
+
len
;
w
++
)
if
(
*
w
!=
0x00
)
break
;
VSB_printf
(
s
,
"0x"
);
if
(
w
==
u
+
len
)
{
VSB_printf
(
s
,
"0...0"
);
}
else
{
for
(
w
=
u
;
w
<
u
+
len
;
w
++
)
VSB_printf
(
s
,
"%02x"
,
*
w
);
}
return
;
}
p
=
v
;
for
(
q
=
p
;
q
<
p
+
len
;
q
++
)
{
if
(
!
isgraph
(
*
q
)
||
*
q
==
'"'
||
*
q
==
'\\'
)
{
...
...
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