From 35b4b12e53e4c671e9c16a1aefb58e0a719aa443 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Chalella?= Date: Tue, 15 Oct 2024 02:11:41 -0300 Subject: [PATCH 01/15] tests 1 & 2 --- test/markdown_test.dart | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/test/markdown_test.dart b/test/markdown_test.dart index 1fea6835..59f72a31 100644 --- a/test/markdown_test.dart +++ b/test/markdown_test.dart @@ -78,6 +78,18 @@ void main() async { 5 Ethernet ([Music]( ''', '''

5 Ethernet ([Music](

+'''); + + validateCore('Incorrect Links - Issue #xxx - Bracketed link 1', ''' +[](< +''', ''' +

[](<

+'''); + + validateCore('Incorrect Links - Issue #xxx - Bracketed link 2', ''' +[](<> +''', ''' +

[](<>

'''); validateCore('Escaping code block language', ''' From bfe9bd662daad8c3a8c725b50e9f928d8586c4b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Chalella?= Date: Tue, 15 Oct 2024 17:10:36 -0300 Subject: [PATCH 02/15] fix 1 --- lib/src/inline_syntaxes/link_syntax.dart | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/src/inline_syntaxes/link_syntax.dart b/lib/src/inline_syntaxes/link_syntax.dart index 7b3c3047..c5e78f99 100644 --- a/lib/src/inline_syntaxes/link_syntax.dart +++ b/lib/src/inline_syntaxes/link_syntax.dart @@ -273,6 +273,7 @@ class LinkSyntax extends DelimiterSyntax { /// Returns the link if it was successfully created, `null` otherwise. InlineLink? _parseInlineBracketedLink(InlineParser parser) { parser.advanceBy(1); + if (parser.isDone) return null; final buffer = StringBuffer(); while (true) { From 90b16cb453aaea10de5031f7018aa5606f3ccb3f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Chalella?= Date: Tue, 15 Oct 2024 17:10:46 -0300 Subject: [PATCH 03/15] fix 2 --- lib/src/inline_syntaxes/link_syntax.dart | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/src/inline_syntaxes/link_syntax.dart b/lib/src/inline_syntaxes/link_syntax.dart index c5e78f99..a971d350 100644 --- a/lib/src/inline_syntaxes/link_syntax.dart +++ b/lib/src/inline_syntaxes/link_syntax.dart @@ -303,6 +303,7 @@ class LinkSyntax extends DelimiterSyntax { final destination = buffer.toString(); parser.advanceBy(1); + if (parser.isDone) return null; final char = parser.charAt(parser.pos); if (char == $space || char == $lf || char == $cr || char == $ff) { final title = _parseTitle(parser); From e20a5b373630845b05c6fdd105ad59e6fe836dc8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Chalella?= Date: Tue, 15 Oct 2024 02:30:38 -0300 Subject: [PATCH 04/15] test 3 --- test/markdown_test.dart | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/test/markdown_test.dart b/test/markdown_test.dart index 59f72a31..68d26369 100644 --- a/test/markdown_test.dart +++ b/test/markdown_test.dart @@ -80,16 +80,22 @@ void main() async {

5 Ethernet ([Music](

'''); - validateCore('Incorrect Links - Issue #xxx - Bracketed link 1', ''' + validateCore('Incorrect Links - Issue #xxx - 1 - Bracketed link 1', ''' [](< ''', '''

[](<

'''); - validateCore('Incorrect Links - Issue #xxx - Bracketed link 2', ''' + validateCore('Incorrect Links - Issue #xxx - 2 - Bracketed link 2', ''' [](<> ''', '''

[](<>

+'''); + + validateCore('Incorrect Links - Issue #xxx - 3 - Link title', ''' +[](www.example.com " +''', ''' +

[](www.example.com "

'''); validateCore('Escaping code block language', ''' From 955b01150c1c679fc3757f30486528173c0d7297 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Chalella?= Date: Tue, 15 Oct 2024 02:30:45 -0300 Subject: [PATCH 05/15] fix 3 --- lib/src/inline_syntaxes/link_syntax.dart | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/src/inline_syntaxes/link_syntax.dart b/lib/src/inline_syntaxes/link_syntax.dart index a971d350..8f9185c4 100644 --- a/lib/src/inline_syntaxes/link_syntax.dart +++ b/lib/src/inline_syntaxes/link_syntax.dart @@ -435,6 +435,7 @@ class LinkSyntax extends DelimiterSyntax { final closeDelimiter = delimiter == $lparen ? $rparen : delimiter; parser.advanceBy(1); + if (parser.isDone) return null; // Now we look for an un-escaped closing delimiter. final buffer = StringBuffer(); From b1e27e491888b35d9406a5e2019b2bcc478bd908 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Chalella?= Date: Tue, 15 Oct 2024 02:35:07 -0300 Subject: [PATCH 06/15] test 4 --- test/markdown_test.dart | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/test/markdown_test.dart b/test/markdown_test.dart index 68d26369..bb917300 100644 --- a/test/markdown_test.dart +++ b/test/markdown_test.dart @@ -92,10 +92,16 @@ void main() async {

[](<>

'''); - validateCore('Incorrect Links - Issue #xxx - 3 - Link title', ''' + validateCore('Incorrect Links - Issue #xxx - 3 - Link title 1', ''' [](www.example.com " ''', '''

[](www.example.com "

+'''); + + validateCore('Incorrect Links - Issue #xxx - 4 - Link title 2', r''' +[](www.example.com "\ +''', r''' +

[](www.example.com "\

'''); validateCore('Escaping code block language', ''' From a0330d580ebc7b848b4f36af0364875ed7a0ae72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Chalella?= Date: Tue, 15 Oct 2024 02:40:56 -0300 Subject: [PATCH 07/15] fix 4 --- lib/src/inline_syntaxes/link_syntax.dart | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/src/inline_syntaxes/link_syntax.dart b/lib/src/inline_syntaxes/link_syntax.dart index 8f9185c4..5e0a6ab0 100644 --- a/lib/src/inline_syntaxes/link_syntax.dart +++ b/lib/src/inline_syntaxes/link_syntax.dart @@ -443,6 +443,7 @@ class LinkSyntax extends DelimiterSyntax { final char = parser.charAt(parser.pos); if (char == $backslash) { parser.advanceBy(1); + if (parser.isDone) return null; final next = parser.charAt(parser.pos); if (next != $backslash && next != closeDelimiter) { buffer.writeCharCode(char); From a18d82c13d492d916f5fec2bea60178dcbfb8d20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Chalella?= Date: Tue, 15 Oct 2024 02:53:12 -0300 Subject: [PATCH 08/15] test 5 --- test/markdown_test.dart | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/test/markdown_test.dart b/test/markdown_test.dart index bb917300..8319a5b9 100644 --- a/test/markdown_test.dart +++ b/test/markdown_test.dart @@ -102,6 +102,12 @@ void main() async { [](www.example.com "\ ''', r'''

[](www.example.com "\

+'''); + + validateCore('Incorrect Links - Issue #xxx - 5 - Reference link label', r''' +[][\ +''', r''' +

[][\

'''); validateCore('Escaping code block language', ''' From f145bbcab957f72b263228b526900d8e33c3b9d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Chalella?= Date: Tue, 15 Oct 2024 02:59:53 -0300 Subject: [PATCH 09/15] fix 5 --- lib/src/inline_syntaxes/link_syntax.dart | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/src/inline_syntaxes/link_syntax.dart b/lib/src/inline_syntaxes/link_syntax.dart index 5e0a6ab0..a7d25c2d 100644 --- a/lib/src/inline_syntaxes/link_syntax.dart +++ b/lib/src/inline_syntaxes/link_syntax.dart @@ -216,6 +216,7 @@ class LinkSyntax extends DelimiterSyntax { final char = parser.charAt(parser.pos); if (char == $backslash) { parser.advanceBy(1); + if (parser.isDone) return null; final next = parser.charAt(parser.pos); if (next != $backslash && next != $rbracket) { buffer.writeCharCode(char); From cfa10ac05e0f76fa8229473b69cb1f0790c57c64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Chalella?= Date: Tue, 15 Oct 2024 03:00:05 -0300 Subject: [PATCH 10/15] test 3bis --- test/markdown_test.dart | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/test/markdown_test.dart b/test/markdown_test.dart index 8319a5b9..ea858f9b 100644 --- a/test/markdown_test.dart +++ b/test/markdown_test.dart @@ -92,19 +92,25 @@ void main() async {

[](<>

'''); - validateCore('Incorrect Links - Issue #xxx - 3 - Link title 1', ''' + validateCore('Incorrect Links - Issue #xxx - 3 - Bracketed link 3', r''' +[](<\ +''', r''' +

[](<\

+'''); + + validateCore('Incorrect Links - Issue #xxx - 4 - Link title 1', ''' [](www.example.com " ''', '''

[](www.example.com "

'''); - validateCore('Incorrect Links - Issue #xxx - 4 - Link title 2', r''' + validateCore('Incorrect Links - Issue #xxx - 5 - Link title 2', r''' [](www.example.com "\ ''', r'''

[](www.example.com "\

'''); - validateCore('Incorrect Links - Issue #xxx - 5 - Reference link label', r''' + validateCore('Incorrect Links - Issue #xxx - 6 - Reference link label', r''' [][\ ''', r'''

[][\

From 912e3657551c16eff3e2426b3adecd521828532c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Chalella?= Date: Tue, 15 Oct 2024 03:00:42 -0300 Subject: [PATCH 11/15] fix 3bis --- lib/src/inline_syntaxes/link_syntax.dart | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/src/inline_syntaxes/link_syntax.dart b/lib/src/inline_syntaxes/link_syntax.dart index a7d25c2d..bca3efbe 100644 --- a/lib/src/inline_syntaxes/link_syntax.dart +++ b/lib/src/inline_syntaxes/link_syntax.dart @@ -281,6 +281,7 @@ class LinkSyntax extends DelimiterSyntax { final char = parser.charAt(parser.pos); if (char == $backslash) { parser.advanceBy(1); + if (parser.isDone) return null; final next = parser.charAt(parser.pos); // TODO: Follow the backslash spec better here. // https://spec.commonmark.org/0.30/#backslash-escapes From 18cc521540a81acd88c34d42b7310f41d07cf5cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Chalella?= Date: Tue, 15 Oct 2024 03:11:38 -0300 Subject: [PATCH 12/15] issue numbers --- test/markdown_test.dart | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/test/markdown_test.dart b/test/markdown_test.dart index ea858f9b..feb2d770 100644 --- a/test/markdown_test.dart +++ b/test/markdown_test.dart @@ -80,37 +80,37 @@ void main() async {

5 Ethernet ([Music](

'''); - validateCore('Incorrect Links - Issue #xxx - 1 - Bracketed link 1', ''' + validateCore('Incorrect Links - Issue #623 - 1 - Bracketed link 1', ''' [](< ''', '''

[](<

'''); - validateCore('Incorrect Links - Issue #xxx - 2 - Bracketed link 2', ''' + validateCore('Incorrect Links - Issue #623 - 2 - Bracketed link 2', ''' [](<> ''', '''

[](<>

'''); - validateCore('Incorrect Links - Issue #xxx - 3 - Bracketed link 3', r''' + validateCore('Incorrect Links - Issue #623 - 3 - Bracketed link 3', r''' [](<\ ''', r'''

[](<\

'''); - validateCore('Incorrect Links - Issue #xxx - 4 - Link title 1', ''' + validateCore('Incorrect Links - Issue #623 - 4 - Link title 1', ''' [](www.example.com " ''', '''

[](www.example.com "

'''); - validateCore('Incorrect Links - Issue #xxx - 5 - Link title 2', r''' + validateCore('Incorrect Links - Issue #623 - 5 - Link title 2', r''' [](www.example.com "\ ''', r'''

[](www.example.com "\

'''); - validateCore('Incorrect Links - Issue #xxx - 6 - Reference link label', r''' + validateCore('Incorrect Links - Issue #623 - 6 - Reference link label', r''' [][\ ''', r'''

[][\

From 738c2ab8168b06cb70c4cdc87503a6335ad10574 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Chalella?= Date: Tue, 15 Oct 2024 03:14:35 -0300 Subject: [PATCH 13/15] version + changelog --- CHANGELOG.md | 4 ++++ pubspec.yaml | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ec5b8904..732f0805 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 7.2.4 + +* Fix several `RangeError` hazards in links (#623). + ## 7.2.3 * Fix an issue with checkbox list items separated with blank lines (#602). diff --git a/pubspec.yaml b/pubspec.yaml index 947b66ea..3862e401 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,5 +1,5 @@ name: markdown -version: 7.2.3 +version: 7.2.4 description: >- A portable Markdown library written in Dart that can parse Markdown into HTML. repository: https://github.com/dart-lang/markdown From 15b64296bae36d62f7dc11a184bcaad5c3aeaa7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Chalella?= Date: Tue, 15 Oct 2024 17:00:20 -0300 Subject: [PATCH 14/15] fix PR failed tests (version.dart) --- lib/src/version.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/src/version.dart b/lib/src/version.dart index 5c4f1b48..e42da0f9 100644 --- a/lib/src/version.dart +++ b/lib/src/version.dart @@ -1,2 +1,2 @@ // Generated code. Do not modify. -const packageVersion = '7.2.3'; +const packageVersion = '7.2.4'; From ed4d0f100fbd5200a36949af6d75c76d1585e18c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Chalella?= Date: Tue, 15 Oct 2024 17:47:44 -0300 Subject: [PATCH 15/15] reset version to 7.2.3 as per srawlins request --- CHANGELOG.md | 5 +---- lib/src/version.dart | 2 +- pubspec.yaml | 2 +- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 732f0805..658d8b68 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,11 +1,8 @@ -## 7.2.4 - -* Fix several `RangeError` hazards in links (#623). - ## 7.2.3 * Fix an issue with checkbox list items separated with blank lines (#602). * Require package `web: '>=0.4.2 <2.0.0'`. +* Fix several `RangeError` hazards in links (#623). ## 7.2.2 diff --git a/lib/src/version.dart b/lib/src/version.dart index e42da0f9..5c4f1b48 100644 --- a/lib/src/version.dart +++ b/lib/src/version.dart @@ -1,2 +1,2 @@ // Generated code. Do not modify. -const packageVersion = '7.2.4'; +const packageVersion = '7.2.3'; diff --git a/pubspec.yaml b/pubspec.yaml index 3862e401..947b66ea 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,5 +1,5 @@ name: markdown -version: 7.2.4 +version: 7.2.3 description: >- A portable Markdown library written in Dart that can parse Markdown into HTML. repository: https://github.com/dart-lang/markdown