Skip to content

Using optional directive in string-like parser results in null ('\0') character being encoded in the result #79

Description

@saki7

This behavior is currently produced by design, but it is very hard to debug. I think we should reconsider and make the string parser silently omit the element when the underlying parser produces an optional attribute.

Consider a markdown-like paragraph:

constexpr auto section_text_def = as<std::string>(
    +(
        lexeme[!lit('#') >> +(char_ - eol)] >>

        // always output the first eol as LF
        ((eol | eoi) >> attr('\n')) >>

        // squash subsequent eols to single LF
        // -(+eol >> attr('\n'))   // <--- this outputs '\0'
        (+eol >> attr('\n') | eps) // <--- workaround
    )
);

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions