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

This commit is contained in:
Jason Simmons
2019-09-19 09:44:31 -07:00
committed by GitHub
parent 0086243be4
commit c94a994d62
2 changed files with 6 additions and 0 deletions

View File

@@ -180,11 +180,16 @@ class LicenseEntryWithLineBreaks extends LicenseEntry {
currentLineIndent += 8;
state = _LicenseEntryWithLineBreaksParserState.beforeParagraph;
break;
case '\r':
case '\n':
case '\f':
if (lines.isNotEmpty) {
yield getParagraph();
}
if (text[currentPosition] == '\r' && currentPosition < text.length - 1
&& text[currentPosition + 1] == '\n') {
currentPosition += 1;
}
lastLineIndent = 0;
currentLineIndent = 0;
currentParagraphIndentation = null;

View File

@@ -158,6 +158,7 @@ S
test('LicenseEntryWithLineBreaks - leading and trailing whitespace', () {
expect(const LicenseEntryWithLineBreaks(null, ' \n\n ').paragraphs.toList(), isEmpty);
expect(const LicenseEntryWithLineBreaks(null, ' \r\n\r\n ').paragraphs.toList(), isEmpty);
List<LicenseParagraph> paragraphs;