Unverified Commit c94a994d authored by Jason Simmons's avatar Jason Simmons Committed by GitHub

Handle CR+LF end of line sequences in the license parser (#40718)

parent 0086243b
...@@ -180,11 +180,16 @@ class LicenseEntryWithLineBreaks extends LicenseEntry { ...@@ -180,11 +180,16 @@ class LicenseEntryWithLineBreaks extends LicenseEntry {
currentLineIndent += 8; currentLineIndent += 8;
state = _LicenseEntryWithLineBreaksParserState.beforeParagraph; state = _LicenseEntryWithLineBreaksParserState.beforeParagraph;
break; break;
case '\r':
case '\n': case '\n':
case '\f': case '\f':
if (lines.isNotEmpty) { if (lines.isNotEmpty) {
yield getParagraph(); yield getParagraph();
} }
if (text[currentPosition] == '\r' && currentPosition < text.length - 1
&& text[currentPosition + 1] == '\n') {
currentPosition += 1;
}
lastLineIndent = 0; lastLineIndent = 0;
currentLineIndent = 0; currentLineIndent = 0;
currentParagraphIndentation = null; currentParagraphIndentation = null;
......
...@@ -158,6 +158,7 @@ S ...@@ -158,6 +158,7 @@ S
test('LicenseEntryWithLineBreaks - leading and trailing whitespace', () { test('LicenseEntryWithLineBreaks - leading and trailing whitespace', () {
expect(const LicenseEntryWithLineBreaks(null, ' \n\n ').paragraphs.toList(), isEmpty); expect(const LicenseEntryWithLineBreaks(null, ' \n\n ').paragraphs.toList(), isEmpty);
expect(const LicenseEntryWithLineBreaks(null, ' \r\n\r\n ').paragraphs.toList(), isEmpty);
List<LicenseParagraph> paragraphs; List<LicenseParagraph> paragraphs;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment