mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 14:48:21 +00:00
Fixed the do_split bug and added a test.
* do_split was having a problem if there was another match after the end of the number of separators. It would only return the match up to the point of the next match instead of the rest of the string.
This commit is contained in:
parent
2bc5e69961
commit
cba5766bc8
3 changed files with 16 additions and 1 deletions
|
@ -225,6 +225,8 @@ Val* do_split(StringVal* str_val, RE_Matcher* re, TableVal* other_sep,
|
||||||
}
|
}
|
||||||
|
|
||||||
Val* ind = new Val(++num, TYPE_COUNT);
|
Val* ind = new Val(++num, TYPE_COUNT);
|
||||||
|
if ( num_sep >= max_num_sep )
|
||||||
|
offset = end_of_s-s;
|
||||||
a->Assign(ind, new StringVal(offset, (const char*) s));
|
a->Assign(ind, new StringVal(offset, (const char*) s));
|
||||||
Unref(ind);
|
Unref(ind);
|
||||||
|
|
||||||
|
|
4
testing/btest/Baseline/bifs.string_splitting/out
Normal file
4
testing/btest/Baseline/bifs.string_splitting/out
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
{
|
||||||
|
[2] = Testing Test (http://www.example.com),
|
||||||
|
[1] = X-Mailer
|
||||||
|
}
|
9
testing/btest/bifs/string_splitting.bro
Normal file
9
testing/btest/bifs/string_splitting.bro
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
#
|
||||||
|
# @TEST-EXEC: bro %INPUT >out
|
||||||
|
# @TEST-EXEC: btest-diff out
|
||||||
|
|
||||||
|
event bro_init()
|
||||||
|
{
|
||||||
|
local a = "X-Mailer: Testing Test (http://www.example.com)";
|
||||||
|
print split1(a, /:[[:blank:]]*/);
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue