Skip to content
This repository has been archived by the owner on May 14, 2024. It is now read-only.

Some objectGUID buffer cause error in escape filter function #10

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions lib/utils/escape-filter-value.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,17 @@ function escapeBuffer (buf) {
for (let i = 0; i < buf.length; i += 1) {
if (buf[i] >= 0xc0 && buf[i] <= 0xdf) {
// Represents the first byte in a 2-byte UTF-8 character.
result += '\\' + buf[i].toString(16) + '\\' + buf[i + 1].toString(16)
result += '\\' + buf[i].toString(16);
if(i<15) { result += '\\' + buf[i + 1].toString(16); } //Only add second byte if exist in buffer
ciePIC marked this conversation as resolved.
Show resolved Hide resolved
i += 1
continue
}

if (buf[i] >= 0xe0 && buf[i] <= 0xef) {
// Represents the first byte in a 3-byte UTF-8 character.
result += [
'\\', buf[i].toString(16),
'\\', buf[i + 1].toString(16),
'\\', buf[i + 2].toString(16)
].join('')
result += '\\' + buf[i].toString(16);
if(i<15) { result += '\\' + buf[i + 1].toString(16); } //Only add second byte if exist in buffer
if(i<14) { result += '\\' + buf[i + 2].toString(16); } //Only add third byte if exist in buffer
ciePIC marked this conversation as resolved.
Show resolved Hide resolved
i += 2
continue
}
Expand Down