[PATCH] D46274: [Support] Harden JSON against invalid UTF-8.
Sam McCall via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 9 05:59:39 PDT 2018
sammccall marked 2 inline comments as done.
sammccall added a comment.
Oops, sorry for losing track of this.
The JSON-in-Support patch has finally landed in r336534 so this can actually go in sometime soon :-)
================
Comment at: lib/Support/JSON.cpp:520
+bool isUTF8(llvm::StringRef S, size_t *ErrOffset) {
+ // Fast-path for ASCII, which is valid UTF-8.
+ for (unsigned char C : S)
----------------
benhamilton wrote:
> Wouldn't it make sense to move this to `isLegalUTF8String()`?
>
Hmm.. maybe. I'm slightly leery about this, as these are common Unicode reference functions that are largely unmodified, which people may expect.
Also I think we'd still want to split it into two functions so the ASCII check can be inlined and the utf-8 wrangling outlined. It seems harmless enough here, but maybe I'm just lazy. WDYT?
Repository:
rL LLVM
https://reviews.llvm.org/D46274
More information about the llvm-commits
mailing list