[PATCH] D44863: Summary:

Graydon Hoare via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 23 22:05:13 PDT 2018


graydon created this revision.
graydon added reviewers: JDevlieghere, thegameg, MatzeB, vladimir.plyashkun.

The existing YAML Output::scalarString code path includes a partial and
incorrect implementation of YAML escaping logic. In particular, the logic put
in place in https://reviews.llvm.org/rL321283 escapes non-printable bytes only if they are not part of a
multibyte UTF8 sequence; implicitly this means that all multibyte UTF8
sequences -- printable and non -- are passed through verbatim.

The simplest solution to this is to direct the Output::scalarString method to
use the standalone yaml::escape function, and this _almost_ works, except that
the existing code in that function _over_ escapes: any multibyte UTF8 sequence
is escaped, even printable ones. While this is permitted for YAML, it is also
more aggressive (and hard to read for non-English locales) than necessary,
and the entire point of https://reviews.llvm.org/rL321283 was to back off such aggressive over-escaping.

So in this change, I have both redirected Output::scalarString to use
yaml::escape _and_ modified yaml::escape to optionally restrict its escaping to
non-printables. This preserves behaviour of any existing clients while giving
them a path to more moderate escaping should they desire.


Repository:
  rL LLVM

https://reviews.llvm.org/D44863

Files:
  include/llvm/Support/YAMLParser.h
  lib/Support/YAMLParser.cpp
  lib/Support/YAMLTraits.cpp
  unittests/Support/YAMLIOTest.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D44863.139698.patch
Type: text/x-patch
Size: 5806 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180324/74577da2/attachment.bin>


More information about the llvm-commits mailing list