Skip to content

Commit

Permalink
2.x: Backport: Allow up to 3 levels of nested comments in ARH (#479)
Browse files Browse the repository at this point in the history
Backport of #466.
  • Loading branch information
dodmi authored Jan 4, 2025
1 parent 2535847 commit 92dcae9
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions modules/rfcParser.jsm.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,13 @@ let rfcParser = (function() {
RfcParserStd.FWS_op = `${RfcParserStd.FWS}?`;
// Note: this is incomplete (obs-ctext is missing)
RfcParserStd.ctext = "[!-'*-[\\]-~]";
// Note: this is incomplete (comment is missing)
RfcParserStd.ccontent = `(?:${RfcParserStd.ctext}|${RfcParserStd.quoted_pair})`;
// Note: There is a recursion in ccontent/comment, which is not supported by the RegExp in JavaScript.
// We currently unroll it to support a depth of up to 3 comments.
RfcParserStd.ccontent_2 = `(?:${RfcParserStd.ctext}|${RfcParserStd.quoted_pair})`;
RfcParserStd.comment_2 = `\\((?:${RfcParserStd.FWS_op}${RfcParserStd.ccontent_2})*${RfcParserStd.FWS_op}\\)`;
RfcParserStd.ccontent_1 = `(?:${RfcParserStd.ctext}|${RfcParserStd.quoted_pair}|${RfcParserStd.comment_2})`;
RfcParserStd.comment_1 = `\\((?:${RfcParserStd.FWS_op}${RfcParserStd.ccontent_1})*${RfcParserStd.FWS_op}\\)`;
RfcParserStd.ccontent = `(?:${RfcParserStd.ctext}|${RfcParserStd.quoted_pair}|${RfcParserStd.comment_1})`;
RfcParserStd.comment = `\\((?:${RfcParserStd.FWS_op}${RfcParserStd.ccontent})*${RfcParserStd.FWS_op}\\)`;
RfcParserStd.CFWS = `(?:(?:(?:${RfcParserStd.FWS_op}${RfcParserStd.comment})+${RfcParserStd.FWS_op})|${RfcParserStd.FWS})`;
// Note: helper only, not part of the RFC
Expand Down

0 comments on commit 92dcae9

Please sign in to comment.