Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions test/markdown/markdown_images_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,10 @@ TEST(image_title_with_escaped_quote) {
EXPECT_EQ(result,
"<p><img src=\"/l.png\" alt=\"logo\" title=\"it&#39;s\" /></p>\n");
}

TEST(image_description_spanning_a_soft_break) {
// The description becomes the alt attribute, which cannot hold a line break,
// so the break is flattened into a single space
const auto result{sourcemeta::core::markdown_to_html("![a\nb](/u)")};
EXPECT_EQ(result, "<p><img src=\"/u\" alt=\"a b\" /></p>\n");
}
6 changes: 6 additions & 0 deletions test/markdown/markdown_links_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -655,3 +655,9 @@ TEST(link_inside_link_text_with_later_bracket_is_not_allowed) {
sourcemeta::core::markdown_to_html("[a [b](/c) [d] e](/u)")};
EXPECT_EQ(result, "<p>[a <a href=\"/c\">b</a> [d] e](/u)</p>\n");
}

TEST(reference_link_label_with_a_space_before_a_non_ascii_character) {
const auto result{sourcemeta::core::markdown_to_html(
"[click][a \u00e9]\n\n[a \u00e9]: https://example.com")};
EXPECT_EQ(result, "<p><a href=\"https://example.com\">click</a></p>\n");
}
9 changes: 9 additions & 0 deletions test/markdown/markdown_unsafe_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -388,3 +388,12 @@ TEST(tagfilter_vertical_tab_does_not_end_tag_name) {
"<xmp\v>a\n"
"</div>\n");
}

TEST(tagfilter_tag_name_ended_by_a_tab) {
// The HTML tokenizer ends a tag name at a tab just as it does at a space, so
// the tag is still one of the disallowed ones and its opening angle bracket
// is escaped
const auto result{
sourcemeta::core::markdown_to_html("x <script\tsrc=y>", false)};
EXPECT_EQ(result, "<p>x &lt;script\tsrc=y></p>\n");
}
Loading