src: fix ParseEncoding · nodejs/node@63cd05b · GitHub
Skip to content

Commit 63cd05b

Browse files
sapicsaddaleax
authored andcommitted
src: fix ParseEncoding
"utf-16LE" was parsed "UNKNOWN", this fixes to "UCS2" "utf-buffer" was parsed "BUFFER", this fixes to "UNKNOWN" "utf-16leNOT" was parsed "UCS2", this fixes to "UNKNOWN" PR-URL: #33957 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent 6ee800f commit 63cd05b

3 files changed

Lines changed: 65 additions & 47 deletions

File tree

src/api/encoding.cc

Lines changed: 58 additions & 41 deletions

src/util-inl.h

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -299,12 +299,10 @@ std::string ToUpper(const std::string& in) {
299299
}
300300

301301
bool StringEqualNoCase(const char* a, const char* b) {
302-
do {
303-
if (*a == '\0')
304-
return *b == '\0';
305-
if (*b == '\0')
306-
return *a == '\0';
307-
} while (ToLower(*a++) == ToLower(*b++));
302+
while (ToLower(*a) == ToLower(*b++)) {
303+
if (*a++ == '\0')
304+
return true;
305+
}
308306
return false;
309307
}
310308

test/addons/parse-encoding/test.js

Lines changed: 3 additions & 0 deletions

0 commit comments

Comments
 (0)