mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 14:48:21 +00:00
Prioritizes escaping predefined Escape Sequences over Unescaping UTF-8 Sequences
This commit is contained in:
parent
d6bcdfce52
commit
3efbea0b84
1 changed files with 7 additions and 6 deletions
13
src/Desc.cc
13
src/Desc.cc
|
@ -261,7 +261,7 @@ size_t check_utf8 (const char* bytes, size_t n, size_t i)
|
||||||
{
|
{
|
||||||
// Check if this is infact a multibyte UTF-8 sequence,
|
// Check if this is infact a multibyte UTF-8 sequence,
|
||||||
// which requires a 1 to be the first bit of the first byte
|
// which requires a 1 to be the first bit of the first byte
|
||||||
if (!(bytes[i] >> 7 & 1))
|
if (!(bytes[i] >> 7 & 1))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
// Checks two to four bytes from starting position i
|
// Checks two to four bytes from starting position i
|
||||||
|
@ -291,7 +291,12 @@ pair<const char*, size_t> ODesc::FirstEscapeLoc(const char* bytes, size_t n)
|
||||||
if (bytes[i] == '\\' )
|
if (bytes[i] == '\\' )
|
||||||
return escape_pos(bytes + i, 1);
|
return escape_pos(bytes + i, 1);
|
||||||
|
|
||||||
else if (!isprint(bytes[i]))
|
size_t len = StartsWithEscapeSequence(bytes + i, bytes + n);
|
||||||
|
|
||||||
|
if ( len )
|
||||||
|
return escape_pos(bytes + i, len);
|
||||||
|
|
||||||
|
if (!isprint(bytes[i]))
|
||||||
{
|
{
|
||||||
if (utf8)
|
if (utf8)
|
||||||
{
|
{
|
||||||
|
@ -305,10 +310,6 @@ pair<const char*, size_t> ODesc::FirstEscapeLoc(const char* bytes, size_t n)
|
||||||
return escape_pos(bytes + i, 1);
|
return escape_pos(bytes + i, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t len = StartsWithEscapeSequence(bytes + i, bytes + n);
|
|
||||||
|
|
||||||
if ( len )
|
|
||||||
return escape_pos(bytes + i, len);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return escape_pos(0, 0);
|
return escape_pos(0, 0);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue