8000 Escape control characters in keys by arp242 · Pull Request #230 · ToruNiina/toml11 · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Escape control characters in keys #230

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 10, 2023
Merged

Escape control characters in keys #230

merged 1 commit into from
Oct 10, 2023

Conversation

arp242
Copy link
Contributor
@arp242 arp242 commented Oct 10, 2023

Previously a key like:

    "a\u0000\u0001b" = 1

Would get written with literal control characters, rather than escapes:

    "a<00><01>b" = 1

The "valid/key/quoted-unicode" test from toml-test would fail with this, although it seems they're not run automatically(?)

Can also reproduce with something like:

    % cat test.cpp
    #include <toml.hpp>
    #include <iostream>

    int main()
    {
            const auto data  = toml::parse("test.toml");
            std::cout << data << "\n";
            return 0;
    }

    % cat test.toml
    "a\u0000\u0001b" = "a\u0000\u0001b"

    % c++ -I. test.cpp

    % ./a.out
    "ab" = "a\u0000\u0001b"

    % ./a.out | hexdump -C
    00000000  22 61 00 01 62 22 20 3d  20 22 61 5c 75 30 30 30  |"a..b" = "a\u000|
    00000010  30 5c 75 30 30 30 31 62  22 0a 0a                 |0\u0001b"..|

Previously a key like:

        "a\u0000\u0001b" = 1

Would get written with literal control characters, rather than escapes:

        "a<00><01>b" = 1

The "valid/key/quoted-unicode" test from toml-test would fail with this,
although i
8000
t seems they're not run automatically(?)

Can also reproduce with something like:

        % cat test.cpp
        #include <toml.hpp>
        #include <iostream>

        int main()
        {
                const auto data  = toml::parse("test.toml");
                std::cout << data << "\n";
                return 0;
        }

        % cat test.toml
        "a\u0000\u0001b" = "a\u0000\u0001b"

        % c++ -I. test.cpp

        % ./a.out
        "ab" = "a\u0000\u0001b"

        % ./a.out | hexdump -C
        00000000  22 61 00 01 62 22 20 3d  20 22 61 5c 75 30 30 30  |"a..b" = "a\u000|
        00000010  30 5c 75 30 30 30 31 62  22 0a 0a                 |0\u0001b"..|
@ToruNiina ToruNiina merged commit 22d96ed into ToruNiina:master Oct 10, 2023
@ToruNiina
Copy link
Owner

Thank you very much!

@arp242 arp242 deleted the t branch October 10, 2023 14:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0