kgiszczak / tomlib Goto Github PK
View Code? Open in Web Editor NEWTomlib is a fast and standards-compliant TOML parser and generator for Ruby.
License: MIT License
Tomlib is a fast and standards-compliant TOML parser and generator for Ruby.
License: MIT License
If a string value contains the sequence #$
, this is incorrectly rendered to the output with an escaped #, which is invalid TOML and cannot be parsed by a compliant parser (including tomlib):
irb(main):001:0> require 'tomlib'
=> true
irb(main):002:0> configuration = {bar: {foo: 'Aa#$298gXsqK9876'} }
=> {:bar=>{:foo=>"Aa\#$298gXsqK9876"}}
irb(main):003:0> puts Tomlib.dump(configuration)
[bar]
foo = "Aa\#$298gXsqK9876"
=> nil
irb(main):004:0> Tomlib.load(Tomlib.dump(configuration))
(irb):4:in `load': line 2: bad escape char (Tomlib::ParseError)
This comes from the use of inspect on the String, which escapes per Ruby rules (where #$
is shorthand for a global variable interpolation, so the # must be escaped by inspect), not per TOML rules. There are other similar character sequences that cause the same issue (e.g. #{
and possibly others).
Trying to parse https://github.com/toml-lang/toml/blob/v1.0.0-rc.1/examples/example-v0.4.0.toml, I've encountered this:
Tomlib.load "key = 1e1000"
# => invalid value (Tomlib::ParseError)
Other toml libs behave like ruby and return Float::INFINITY
instead
TomlRB.parse "key = 1e1000"
# => {"key"=>Infinity}
1e1000
# => Infinity
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.