ietf-tools / bap

An ABNF parser, focusing on human-friendly error messages.
41 stars 28 forks source link

Invalid parsing of valid grammar: bap is not RFC-compliant #40

Closed pandatix closed 3 months ago

pandatix commented 3 months ago

Hello, while diving in edge cases of ABNF grammars, I realized there are cases where bap does not parse valid grammars, such as the following one.

;r       (      `ZD/    i
l0-23S    ; ,                     %     Tb
        ;       Rd      i*
        =

 "!j!!`! !V!SX#!/"      ; ]     I H                       z|i
        ;2      oN,(^

        733100338995%B100011110110000;,

 ;u  HAU                5 F$
 (
                        ;u#       <L    WP9WK
 ;      5R?"cq U

 ;      8+

 ; K    /       Q?7     p       -
        ; iZEwRK# /
        *<>)             ;
        ;
 ;
 4225803774834863S;
;

This case, even if seems strange, is completely valid: the defined-as rule in RFC 5234 could produce a c-wsp (the second one, at the end of its definition), which itself could become a comment, producing a whitespace then a CRLF (without an actual comment produced by the repetition of VCHAR). The rule is then concatenated to elements and produce the char-val "a".

This makes bap not RFC-compliant.

pandatix commented 3 months ago

Ok my bad seems like the copy-pasta between terminals and the frontend removed wihtespaces... sorry !