Skip to content

Commit 5c5d430

Browse files
isooskevmoo
authored andcommittedJul 19, 2017
Fix NPE in markdown link rewriter. Fixes #233. (#234)
1 parent 68439e4 commit 5c5d430

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed
 

‎app/lib/shared/markdown.dart

+2-2
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class _RelativeLinkSyntax extends m.LinkSyntax {
4242
@override
4343
m.Link getLink(m.InlineParser parser, Match match, m.TagState state) {
4444
final m.Link link = super.getLink(parser, match, state);
45-
if (_isRelativePathUrl(link.url)) {
45+
if (link != null && _isRelativePathUrl(link.url)) {
4646
final Uri newUri = new Uri(
4747
scheme: baseUri.scheme,
4848
host: baseUri.host,
@@ -56,7 +56,7 @@ class _RelativeLinkSyntax extends m.LinkSyntax {
5656
}
5757

5858
bool _isRelativePathUrl(String url) =>
59-
!url.startsWith('#') && !url.contains(':');
59+
url != null && !url.startsWith('#') && !url.contains(':');
6060
}
6161

6262
m.ExtensionSet _createCustomExtension(String baseUrl) {

‎app/test/shared/markdown_test.dart

+7
Original file line numberDiff line numberDiff line change
@@ -74,4 +74,11 @@ void main() {
7474
'<p><a href="README.md">text</a></p>\n');
7575
});
7676
});
77+
78+
group('Bad markdown', () {
79+
test('bad link', () {
80+
expect(markdownToHtml('[a][b]', 'http://www.example.com/'),
81+
'<p>[a][b]</p>\n');
82+
});
83+
});
7784
}

0 commit comments

Comments
 (0)
Please sign in to comment.