diff options
author | Ralph Amissah <ralph.amissah@gmail.com> | 2023-06-04 20:24:27 -0400 |
---|---|---|
committer | Ralph Amissah <ralph.amissah@gmail.com> | 2023-06-04 20:24:27 -0400 |
commit | 7973da975eac7cf5155a140e4cb4f68d5cbb1eb9 (patch) | |
tree | 447a05d248c217b75b97c497d0a172204eeb8d7f /src/ext_depends/D-YAML/source/dyaml/escapes.d | |
parent | nix use overlays when convenient (diff) |
make set_depends (dyaml update)
Diffstat (limited to 'src/ext_depends/D-YAML/source/dyaml/escapes.d')
-rw-r--r-- | src/ext_depends/D-YAML/source/dyaml/escapes.d | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/src/ext_depends/D-YAML/source/dyaml/escapes.d b/src/ext_depends/D-YAML/source/dyaml/escapes.d index 32080a2..36fd744 100644 --- a/src/ext_depends/D-YAML/source/dyaml/escapes.d +++ b/src/ext_depends/D-YAML/source/dyaml/escapes.d @@ -11,7 +11,7 @@ package: import std.meta : AliasSeq; alias escapes = AliasSeq!('0', 'a', 'b', 't', '\t', 'n', 'v', 'f', 'r', 'e', ' ', - '\"', '\\', 'N', '_', 'L', 'P'); + '/', '\"', '\\', 'N', '_', 'L', 'P'); /// YAML hex codes specifying the length of the hex number. alias escapeHexCodeList = AliasSeq!('x', 'u', 'U'); @@ -31,6 +31,7 @@ dchar fromEscape(dchar escape) @safe pure nothrow @nogc case 'f': return '\x0C'; case 'r': return '\x0D'; case 'e': return '\x1B'; + case '/': return '/'; case ' ': return '\x20'; case '\"': return '\"'; case '\\': return '\\'; @@ -90,3 +91,16 @@ uint escapeHexLength(dchar hexCode) @safe pure nothrow @nogc } } +// Issue #302: Support optional escaping of forward slashes in string +// for JSON compatibility +@safe unittest +{ + import dyaml.loader : Loader; + + const str = `{ + "forward/slashes": "can\/be\/optionally\/escaped" +}`; + + auto node = Loader.fromString(str).load(); + assert(node["forward/slashes"] == "can/be/optionally/escaped"); +} |