mirror of
https://github.com/zeek/zeek.git
synced 2025-10-17 05:58:20 +00:00
In bifs, change ODesc objects to have RAW_STYLE.
This prevents double-escaping with the logging changes of BIT-1333.
This commit is contained in:
parent
7344052b50
commit
7225221c2a
6 changed files with 23 additions and 5 deletions
|
@ -1 +1 @@
|
||||||
Subproject commit 1a2ab9ee7c80ca905e86a2a11283e7c0477341a9
|
Subproject commit a5f4bd828662f3a9f4050747dfca4fb216bdb443
|
11
src/bro.bif
11
src/bro.bif
|
@ -128,6 +128,7 @@ static void do_fmt(const char*& fmt, Val* v, ODesc* d)
|
||||||
char out_buf[512];
|
char out_buf[512];
|
||||||
|
|
||||||
ODesc s;
|
ODesc s;
|
||||||
|
s.SetStyle(RAW_STYLE);
|
||||||
|
|
||||||
if ( precision >= 0 && *fmt != 'e' && *fmt != 'f' && *fmt != 'g' )
|
if ( precision >= 0 && *fmt != 'e' && *fmt != 'f' && *fmt != 'g' )
|
||||||
builtin_error("precision specified for non-floating point");
|
builtin_error("precision specified for non-floating point");
|
||||||
|
@ -250,12 +251,12 @@ static void do_fmt(const char*& fmt, Val* v, ODesc* d)
|
||||||
d->Add(" ");
|
d->Add(" ");
|
||||||
}
|
}
|
||||||
|
|
||||||
d->Add(s.Description());
|
d->AddN((const char*)(s.Bytes()), s.Len());
|
||||||
|
|
||||||
// Right-padding with whitespace, if any.
|
// Right-padding with whitespace, if any.
|
||||||
if ( field_width > 0 && left_just )
|
if ( field_width > 0 && left_just )
|
||||||
{
|
{
|
||||||
int sl = strlen(s.Description());
|
int sl = s.Len();
|
||||||
while ( ++sl <= field_width )
|
while ( ++sl <= field_width )
|
||||||
d->Add(" ");
|
d->Add(" ");
|
||||||
}
|
}
|
||||||
|
@ -1342,6 +1343,8 @@ function order%(v: any, ...%) : index_vec
|
||||||
function cat%(...%): string
|
function cat%(...%): string
|
||||||
%{
|
%{
|
||||||
ODesc d;
|
ODesc d;
|
||||||
|
d.SetStyle(RAW_STYLE);
|
||||||
|
|
||||||
loop_over_list(@ARG@, i)
|
loop_over_list(@ARG@, i)
|
||||||
@ARG@[i]->Describe(&d);
|
@ARG@[i]->Describe(&d);
|
||||||
|
|
||||||
|
@ -1367,6 +1370,8 @@ function cat%(...%): string
|
||||||
function cat_sep%(sep: string, def: string, ...%): string
|
function cat_sep%(sep: string, def: string, ...%): string
|
||||||
%{
|
%{
|
||||||
ODesc d;
|
ODesc d;
|
||||||
|
d.SetStyle(RAW_STYLE);
|
||||||
|
|
||||||
int pre_size = 0;
|
int pre_size = 0;
|
||||||
|
|
||||||
loop_over_list(@ARG@, i)
|
loop_over_list(@ARG@, i)
|
||||||
|
@ -1443,6 +1448,8 @@ function fmt%(...%): string
|
||||||
|
|
||||||
const char* fmt = fmt_v->AsString()->CheckString();
|
const char* fmt = fmt_v->AsString()->CheckString();
|
||||||
ODesc d;
|
ODesc d;
|
||||||
|
d.SetStyle(RAW_STYLE);
|
||||||
|
|
||||||
int n = 0;
|
int n = 0;
|
||||||
|
|
||||||
while ( next_fmt(fmt, @ARGS@, &d, n) )
|
while ( next_fmt(fmt, @ARGS@, &d, n) )
|
||||||
|
|
|
@ -207,6 +207,8 @@ function join_string_array%(sep: string, a: string_array%): string &deprecated
|
||||||
function join_string_vec%(vec: string_vec, sep: string%): string
|
function join_string_vec%(vec: string_vec, sep: string%): string
|
||||||
%{
|
%{
|
||||||
ODesc d;
|
ODesc d;
|
||||||
|
d.SetStyle(RAW_STYLE);
|
||||||
|
|
||||||
VectorVal *v = vec->AsVectorVal();
|
VectorVal *v = vec->AsVectorVal();
|
||||||
|
|
||||||
for ( unsigned i = 0; i < v->Size(); ++i )
|
for ( unsigned i = 0; i < v->Size(); ++i )
|
||||||
|
|
|
@ -4,6 +4,8 @@ AB\xffCD\x00
|
||||||
|
|
||||||
abc\x00def
|
abc\x00def
|
||||||
|
|
||||||
|
abc\x00def
|
||||||
|
|
||||||
foo \xc2\xae bar \xc2\xae baz
|
foo \xc2\xae bar \xc2\xae baz
|
||||||
foo\x00bar\0baz
|
foo\x00bar\0baz
|
||||||
foo \x0e bar ^N baz
|
foo \x0e bar ^N baz
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
#empty_field (empty)
|
#empty_field (empty)
|
||||||
#unset_field -
|
#unset_field -
|
||||||
#path test
|
#path test
|
||||||
#open 2015-04-15-23-47-40
|
#open 2015-04-17-03-37-33
|
||||||
#fields s
|
#fields s
|
||||||
#types string
|
#types string
|
||||||
AB\x00CD\x00
|
AB\x00CD\x00
|
||||||
|
@ -12,7 +12,9 @@ AB\\xffCD\x00
|
||||||
|
|
||||||
abc\\x00def
|
abc\\x00def
|
||||||
|
|
||||||
|
abc\x00def
|
||||||
|
|
||||||
foo \xc2\xae bar \\xc2\\xae baz
|
foo \xc2\xae bar \\xc2\\xae baz
|
||||||
foo\x00bar\\0baz
|
foo\x00bar\\0baz
|
||||||
foo \x0e bar ^N baz
|
foo \x0e bar ^N baz
|
||||||
#close 2015-04-15-23-47-40
|
#close 2015-04-17-03-37-33
|
||||||
|
|
|
@ -16,6 +16,7 @@ event bro_init()
|
||||||
{
|
{
|
||||||
local a = "abc\0def";
|
local a = "abc\0def";
|
||||||
local b = escape_string(a);
|
local b = escape_string(a);
|
||||||
|
local c = fmt("%s", a);
|
||||||
|
|
||||||
Log::create_stream(Test::LOG, [$columns=Log]);
|
Log::create_stream(Test::LOG, [$columns=Log]);
|
||||||
Log::write(Test::LOG, [$s="AB\0CD\0"]);
|
Log::write(Test::LOG, [$s="AB\0CD\0"]);
|
||||||
|
@ -24,6 +25,8 @@ event bro_init()
|
||||||
Log::write(Test::LOG, [$s=" "]);
|
Log::write(Test::LOG, [$s=" "]);
|
||||||
Log::write(Test::LOG, [$s=b]);
|
Log::write(Test::LOG, [$s=b]);
|
||||||
Log::write(Test::LOG, [$s=" "]);
|
Log::write(Test::LOG, [$s=" "]);
|
||||||
|
Log::write(Test::LOG, [$s=c]);
|
||||||
|
Log::write(Test::LOG, [$s=" "]);
|
||||||
Log::write(Test::LOG, [$s="foo \xc2\xae bar \\xc2\\xae baz"]);
|
Log::write(Test::LOG, [$s="foo \xc2\xae bar \\xc2\\xae baz"]);
|
||||||
Log::write(Test::LOG, [$s="foo\x00bar\\0baz"]);
|
Log::write(Test::LOG, [$s="foo\x00bar\\0baz"]);
|
||||||
Log::write(Test::LOG, [$s="foo \16 bar ^N baz"]);
|
Log::write(Test::LOG, [$s="foo \16 bar ^N baz"]);
|
||||||
|
@ -34,6 +37,8 @@ event bro_init()
|
||||||
print "";
|
print "";
|
||||||
print b;
|
print b;
|
||||||
print "";
|
print "";
|
||||||
|
print c;
|
||||||
|
print "";
|
||||||
print "foo \xc2\xae bar \\xc2\\xae baz";
|
print "foo \xc2\xae bar \\xc2\\xae baz";
|
||||||
print "foo\x00bar\\0baz";
|
print "foo\x00bar\\0baz";
|
||||||
print "foo \16 bar ^N baz";
|
print "foo \16 bar ^N baz";
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue