diff options
-rw-r--r-- | src/content-parser.c | 14 | ||||
-rw-r--r-- | tests/check_content_parser.c | 8 |
2 files changed, 15 insertions, 7 deletions
diff --git a/src/content-parser.c b/src/content-parser.c index fa17ab8..8821a17 100644 --- a/src/content-parser.c +++ b/src/content-parser.c @@ -109,7 +109,7 @@ blogc_content_parse_inline(const char *src) switch (c) { case '\\': - if (open_code || open_code_double) { + if (state == LINK_CLOSED && (open_code || open_code_double)) { b_string_append_c(rv, c); break; } @@ -119,7 +119,7 @@ blogc_content_parse_inline(const char *src) case '*': case '_': - if (open_code || open_code_double) { + if (state == LINK_CLOSED && (open_code || open_code_double)) { b_string_append_c(rv, c); break; } @@ -176,7 +176,7 @@ blogc_content_parse_inline(const char *src) break; case '!': - if (open_code || open_code_double) { + if (state == LINK_CLOSED && (open_code || open_code_double)) { b_string_append_c(rv, c); break; } @@ -188,7 +188,7 @@ blogc_content_parse_inline(const char *src) break; case '[': - if (open_code || open_code_double) { + if (state == LINK_CLOSED && (open_code || open_code_double)) { b_string_append_c(rv, c); break; } @@ -212,7 +212,7 @@ blogc_content_parse_inline(const char *src) break; case ']': - if (open_code || open_code_double) { + if (state == LINK_CLOSED && (open_code || open_code_double)) { b_string_append_c(rv, c); break; } @@ -246,7 +246,7 @@ blogc_content_parse_inline(const char *src) break; case '(': - if (open_code || open_code_double) { + if (state == LINK_CLOSED && (open_code || open_code_double)) { b_string_append_c(rv, c); break; } @@ -260,7 +260,7 @@ blogc_content_parse_inline(const char *src) break; case ')': - if (open_code || open_code_double) { + if (state == LINK_CLOSED && (open_code || open_code_double)) { b_string_append_c(rv, c); break; } diff --git a/tests/check_content_parser.c b/tests/check_content_parser.c index 365b309..cb497cb 100644 --- a/tests/check_content_parser.c +++ b/tests/check_content_parser.c @@ -862,6 +862,14 @@ test_content_parse_inline_link(void **state) assert_non_null(html); assert_string_equal(html, "<a href=\"http://example.org/\">bo\nla</a>\n"); free(html); + html = blogc_content_parse_inline("[``bola``](http://example.org/)\n"); + assert_non_null(html); + assert_string_equal(html, "<a href=\"http://example.org/\"><code>bola</code></a>\n"); + free(html); + html = blogc_content_parse_inline("[``bola(2)[3]**!\\``](http://example.org/)\n"); + assert_non_null(html); + assert_string_equal(html, "<a href=\"http://example.org/\"><code>bola(2)[3]**!\\</code></a>\n"); + free(html); // "invalid" html = blogc_content_parse_inline("[bola](\nhttp://example.org/)\n"); assert_non_null(html); |