YAML 1.1 has just zero as an octal prefix: <a href="http://www.yaml.org/spec/1.1/#id858600">http://www.yaml.org/spec/1.1/#id858600</a><br><br><div>This seems to be the behavior of the most popular YAML readers I can get my hands on:</div>
<div><div>irb(main):002:0> YAML.load("010")</div><div>=> 8</div></div><div><br></div><div><div>>>> yaml.load("010")</div><div>8</div></div><div><br></div><div><br></div><div>We get the distinction between strings and integers wrong without this change.  It's pretty easy to see this if you serialize a StringRef holding a decimal (like "3") or hexadecimal number (like "0x3"), we will write it out unquoted which turns it into a number.</div>
<br><div>On Wed Apr 09 2014 at 7:50:30 AM, Michael Spencer <<a href="mailto:bigcheesegs@gmail.com">bigcheesegs@gmail.com</a>> wrote:</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
On Wed, Apr 9, 2014 at 8:56 AM, David Majnemer <<a href="mailto:david.majnemer@gmail.com" target="_blank">david.majnemer@gmail.com</a>> wrote:<br>
> Author: majnemer<br>
> Date: Wed Apr  9 02:56:27 2014<br>
> New Revision: 205839<br>
><br>
> URL: <a href="http://llvm.org/viewvc/llvm-project?rev=205839&view=rev" target="_blank">http://llvm.org/viewvc/llvm-<u></u>project?rev=205839&view=rev</a><br>
> Log:<br>
> YAMLIO: Encode ambiguous hex strings explicitly<br>
><br>
> YAMLIO would turn a BinaryRef into the string 0000000004000000.<br>
> However, the leading zero causes parsers to interpret it as being an<br>
> octal number instead of a hexadecimal one.<br>
><br>
> Instead, escape such strings as needed.<br>
><br>
<br>
This is wrong. In YAML all numbers are treated as decimal. Also this<br>
changes the tag type of the value to !!str.<br>
<br>
The correct change is to fix the reader to always do decimal and<br>
handle the 0x and 0o prefixes.<br>
<br>
See: <a href="http://www.yaml.org/spec/1.2/spec.html#id2805071" target="_blank">http://www.yaml.org/spec/1.2/<u></u>spec.html#id2805071</a><br>
<br>
- Michael Spencer<br>
</blockquote>