aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/content-parser.c2
-rw-r--r--tests/check_content_parser.c319
2 files changed, 321 insertions, 0 deletions
diff --git a/src/content-parser.c b/src/content-parser.c
index a9ab9af..8bdd861 100644
--- a/src/content-parser.c
+++ b/src/content-parser.c
@@ -1043,6 +1043,8 @@ hr:
goto para;
if (c == ' ' || c == '\t')
break;
+ if (c == '\n' || c == '\r')
+ goto param_end;
prefix = b_strndup(src + start2, current - start2);
state = CONTENT_DIRECTIVE_PARAM_PREFIX;
current--;
diff --git a/tests/check_content_parser.c b/tests/check_content_parser.c
index dfb1ffb..86ff1d0 100644
--- a/tests/check_content_parser.c
+++ b/tests/check_content_parser.c
@@ -1238,6 +1238,325 @@ test_content_parse_directive(void **state)
free(html);
will_return(__wrap_blogc_directive_loader, "bola");
+ will_return(__wrap_blogc_directive_loader, NULL);
+ will_return(__wrap_blogc_directive_loader, 0);
+ will_return(__wrap_blogc_directive_loader, "bola");
+ will_return(__wrap_blogc_directive_loader, NULL);
+ will_return(__wrap_blogc_directive_loader, 0);
+ html = blogc_content_parse(
+ "# foo\n"
+ "\n"
+ ".. bola::\n"
+ "\n"
+ ".. bola::", NULL);
+ assert_non_null(html);
+ assert_string_equal(html,
+ "<h1 id=\"foo\">foo</h1>\n"
+ "CHUNDA\n"
+ "CHUNDA\n");
+ free(html);
+
+ will_return(__wrap_blogc_directive_loader, "bola");
+ will_return(__wrap_blogc_directive_loader, "asd");
+ will_return(__wrap_blogc_directive_loader, 0);
+ will_return(__wrap_blogc_directive_loader, "bola");
+ will_return(__wrap_blogc_directive_loader, "asd");
+ will_return(__wrap_blogc_directive_loader, 0);
+ html = blogc_content_parse(
+ "# foo\n"
+ "\n"
+ ".. bola:: asd\n"
+ "\n"
+ ".. bola:: asd\n", NULL);
+ assert_non_null(html);
+ assert_string_equal(html,
+ "<h1 id=\"foo\">foo</h1>\n"
+ "CHUNDA\n"
+ "CHUNDA\n");
+ free(html);
+
+ will_return(__wrap_blogc_directive_loader, "bola");
+ will_return(__wrap_blogc_directive_loader, NULL);
+ will_return(__wrap_blogc_directive_loader, 0);
+ will_return(__wrap_blogc_directive_loader, "bola");
+ will_return(__wrap_blogc_directive_loader, NULL);
+ will_return(__wrap_blogc_directive_loader, 0);
+ html = blogc_content_parse(
+ "# foo\r\n"
+ "\r\n"
+ ".. bola::\r\n"
+ "\r\n"
+ ".. bola::\r\n", NULL);
+ assert_non_null(html);
+ assert_string_equal(html,
+ "<h1 id=\"foo\">foo</h1>\r\n"
+ "CHUNDA\n"
+ "CHUNDA\n");
+ free(html);
+
+ will_return(__wrap_blogc_directive_loader, "bola");
+ will_return(__wrap_blogc_directive_loader, NULL);
+ will_return(__wrap_blogc_directive_loader, 1);
+ will_return(__wrap_blogc_directive_loader, "asd");
+ will_return(__wrap_blogc_directive_loader, "qwe");
+ will_return(__wrap_blogc_directive_loader, "bola");
+ will_return(__wrap_blogc_directive_loader, NULL);
+ will_return(__wrap_blogc_directive_loader, 0);
+ html = blogc_content_parse(
+ "# foo\n"
+ "\n"
+ ".. bola::\n"
+ " :asd: qwe\n"
+ "\n"
+ ".. bola::", NULL);
+ assert_non_null(html);
+ assert_string_equal(html,
+ "<h1 id=\"foo\">foo</h1>\n"
+ "CHUNDA\n"
+ "CHUNDA\n");
+ free(html);
+
+ will_return(__wrap_blogc_directive_loader, "bola");
+ will_return(__wrap_blogc_directive_loader, "asd");
+ will_return(__wrap_blogc_directive_loader, 1);
+ will_return(__wrap_blogc_directive_loader, "asd");
+ will_return(__wrap_blogc_directive_loader, "qwe");
+ will_return(__wrap_blogc_directive_loader, "bola");
+ will_return(__wrap_blogc_directive_loader, "asd");
+ will_return(__wrap_blogc_directive_loader, 0);
+ html = blogc_content_parse(
+ "# foo\n"
+ "\n"
+ ".. bola:: asd\n"
+ " :asd: qwe\n"
+ "\n"
+ ".. bola:: asd\n", NULL);
+ assert_non_null(html);
+ assert_string_equal(html,
+ "<h1 id=\"foo\">foo</h1>\n"
+ "CHUNDA\n"
+ "CHUNDA\n");
+ free(html);
+
+ will_return(__wrap_blogc_directive_loader, "bola");
+ will_return(__wrap_blogc_directive_loader, NULL);
+ will_return(__wrap_blogc_directive_loader, 1);
+ will_return(__wrap_blogc_directive_loader, "asd");
+ will_return(__wrap_blogc_directive_loader, "qwe");
+ will_return(__wrap_blogc_directive_loader, "bola");
+ will_return(__wrap_blogc_directive_loader, NULL);
+ will_return(__wrap_blogc_directive_loader, 0);
+ html = blogc_content_parse(
+ "# foo\n"
+ "\n"
+ ".. bola::\n"
+ " :asd: qwe\n"
+ "\n"
+ ".. bola::\n", NULL);
+ assert_non_null(html);
+ assert_string_equal(html,
+ "<h1 id=\"foo\">foo</h1>\n"
+ "CHUNDA\n"
+ "CHUNDA\n");
+ free(html);
+
+ will_return(__wrap_blogc_directive_loader, "bola");
+ will_return(__wrap_blogc_directive_loader, NULL);
+ will_return(__wrap_blogc_directive_loader, 1);
+ will_return(__wrap_blogc_directive_loader, "asd");
+ will_return(__wrap_blogc_directive_loader, "qwe");
+ will_return(__wrap_blogc_directive_loader, "bola");
+ will_return(__wrap_blogc_directive_loader, NULL);
+ will_return(__wrap_blogc_directive_loader, 0);
+ html = blogc_content_parse(
+ "# foo\r\n"
+ "\r\n"
+ ".. bola::\r\n"
+ " :asd: qwe\r\n"
+ "\r\n"
+ ".. bola::\r\n", NULL);
+ assert_non_null(html);
+ assert_string_equal(html,
+ "<h1 id=\"foo\">foo</h1>\r\n"
+ "CHUNDA\n"
+ "CHUNDA\n");
+ free(html);
+
+ will_return(__wrap_blogc_directive_loader, "bola");
+ will_return(__wrap_blogc_directive_loader, NULL);
+ will_return(__wrap_blogc_directive_loader, 1);
+ will_return(__wrap_blogc_directive_loader, "asd");
+ will_return(__wrap_blogc_directive_loader, "qwe");
+ will_return(__wrap_blogc_directive_loader, "bola");
+ will_return(__wrap_blogc_directive_loader, NULL);
+ will_return(__wrap_blogc_directive_loader, 1);
+ will_return(__wrap_blogc_directive_loader, "asd");
+ will_return(__wrap_blogc_directive_loader, "zxc");
+ html = blogc_content_parse(
+ "# foo\n"
+ "\n"
+ ".. bola::\n"
+ " :asd: qwe\n"
+ "\n"
+ ".. bola::\n"
+ " :asd: zxc\n", NULL);
+ assert_non_null(html);
+ assert_string_equal(html,
+ "<h1 id=\"foo\">foo</h1>\n"
+ "CHUNDA\n"
+ "CHUNDA\n");
+ free(html);
+
+ will_return(__wrap_blogc_directive_loader, "bola");
+ will_return(__wrap_blogc_directive_loader, NULL);
+ will_return(__wrap_blogc_directive_loader, 1);
+ will_return(__wrap_blogc_directive_loader, "asd");
+ will_return(__wrap_blogc_directive_loader, "qwe");
+ will_return(__wrap_blogc_directive_loader, "bola");
+ will_return(__wrap_blogc_directive_loader, NULL);
+ will_return(__wrap_blogc_directive_loader, 1);
+ will_return(__wrap_blogc_directive_loader, "asd");
+ will_return(__wrap_blogc_directive_loader, "zxc");
+ html = blogc_content_parse(
+ "# foo\r\n"
+ "\r\n"
+ ".. bola::\r\n"
+ " :asd: qwe\r\n"
+ "\r\n"
+ ".. bola::\r\n"
+ " :asd: zxc\r\n", NULL);
+ assert_non_null(html);
+ assert_string_equal(html,
+ "<h1 id=\"foo\">foo</h1>\r\n"
+ "CHUNDA\n"
+ "CHUNDA\n");
+ free(html);
+
+ will_return(__wrap_blogc_directive_loader, "bola");
+ will_return(__wrap_blogc_directive_loader, NULL);
+ will_return(__wrap_blogc_directive_loader, 2);
+ will_return(__wrap_blogc_directive_loader, "asd");
+ will_return(__wrap_blogc_directive_loader, "qwe");
+ will_return(__wrap_blogc_directive_loader, "qwe");
+ will_return(__wrap_blogc_directive_loader, "123");
+ will_return(__wrap_blogc_directive_loader, "bola");
+ will_return(__wrap_blogc_directive_loader, NULL);
+ will_return(__wrap_blogc_directive_loader, 2);
+ will_return(__wrap_blogc_directive_loader, "asd");
+ will_return(__wrap_blogc_directive_loader, "qwe");
+ will_return(__wrap_blogc_directive_loader, "qwe");
+ will_return(__wrap_blogc_directive_loader, "456");
+ html = blogc_content_parse(
+ "# foo\n"
+ "\n"
+ ".. bola::\n"
+ " :asd: qwe\n"
+ " :qwe: 123\n"
+ "\n"
+ ".. bola::\n"
+ " :asd: qwe\n"
+ " :qwe: 456", NULL);
+ assert_non_null(html);
+ assert_string_equal(html,
+ "<h1 id=\"foo\">foo</h1>\n"
+ "CHUNDA\n"
+ "CHUNDA\n");
+ free(html);
+
+ will_return(__wrap_blogc_directive_loader, "bola");
+ will_return(__wrap_blogc_directive_loader, "asd");
+ will_return(__wrap_blogc_directive_loader, 2);
+ will_return(__wrap_blogc_directive_loader, "asd");
+ will_return(__wrap_blogc_directive_loader, "qwe");
+ will_return(__wrap_blogc_directive_loader, "qwe");
+ will_return(__wrap_blogc_directive_loader, "123");
+ will_return(__wrap_blogc_directive_loader, "bola");
+ will_return(__wrap_blogc_directive_loader, "asd");
+ will_return(__wrap_blogc_directive_loader, 2);
+ will_return(__wrap_blogc_directive_loader, "asd");
+ will_return(__wrap_blogc_directive_loader, "qwe");
+ will_return(__wrap_blogc_directive_loader, "qwe");
+ will_return(__wrap_blogc_directive_loader, "456");
+ html = blogc_content_parse(
+ "# foo\n"
+ "\n"
+ ".. bola:: asd\n"
+ " :asd: qwe\n"
+ " :qwe: 123\n"
+ "\n"
+ ".. bola:: asd\n"
+ " :asd: qwe\n"
+ " :qwe: 456\n", NULL);
+ assert_non_null(html);
+ assert_string_equal(html,
+ "<h1 id=\"foo\">foo</h1>\n"
+ "CHUNDA\n"
+ "CHUNDA\n");
+ free(html);
+
+ will_return(__wrap_blogc_directive_loader, "bola");
+ will_return(__wrap_blogc_directive_loader, NULL);
+ will_return(__wrap_blogc_directive_loader, 2);
+ will_return(__wrap_blogc_directive_loader, "asd");
+ will_return(__wrap_blogc_directive_loader, "qwe");
+ will_return(__wrap_blogc_directive_loader, "qwe");
+ will_return(__wrap_blogc_directive_loader, "123");
+ will_return(__wrap_blogc_directive_loader, "bola");
+ will_return(__wrap_blogc_directive_loader, NULL);
+ will_return(__wrap_blogc_directive_loader, 2);
+ will_return(__wrap_blogc_directive_loader, "asd");
+ will_return(__wrap_blogc_directive_loader, "qwe");
+ will_return(__wrap_blogc_directive_loader, "qwe");
+ will_return(__wrap_blogc_directive_loader, "456");
+ html = blogc_content_parse(
+ "# foo\n"
+ "\n"
+ ".. bola::\n"
+ " :asd: qwe\n"
+ " :qwe: 123\n"
+ "\n"
+ ".. bola::\n"
+ " :asd: qwe\n"
+ " :qwe: 456\n", NULL);
+ assert_non_null(html);
+ assert_string_equal(html,
+ "<h1 id=\"foo\">foo</h1>\n"
+ "CHUNDA\n"
+ "CHUNDA\n");
+ free(html);
+
+ will_return(__wrap_blogc_directive_loader, "bola");
+ will_return(__wrap_blogc_directive_loader, NULL);
+ will_return(__wrap_blogc_directive_loader, 2);
+ will_return(__wrap_blogc_directive_loader, "asd");
+ will_return(__wrap_blogc_directive_loader, "qwe");
+ will_return(__wrap_blogc_directive_loader, "qwe");
+ will_return(__wrap_blogc_directive_loader, "123");
+ will_return(__wrap_blogc_directive_loader, "bola");
+ will_return(__wrap_blogc_directive_loader, NULL);
+ will_return(__wrap_blogc_directive_loader, 2);
+ will_return(__wrap_blogc_directive_loader, "asd");
+ will_return(__wrap_blogc_directive_loader, "qwe");
+ will_return(__wrap_blogc_directive_loader, "qwe");
+ will_return(__wrap_blogc_directive_loader, "456");
+ html = blogc_content_parse(
+ "# foo\r\n"
+ "\r\n"
+ ".. bola::\r\n"
+ " :asd: qwe\r\n"
+ " :qwe: 123\r\n"
+ "\r\n"
+ ".. bola::\r\n"
+ " :asd: qwe\r\n"
+ " :qwe: 456\r\n", NULL);
+ assert_non_null(html);
+ assert_string_equal(html,
+ "<h1 id=\"foo\">foo</h1>\r\n"
+ "CHUNDA\n"
+ "CHUNDA\n");
+ free(html);
+
+ will_return(__wrap_blogc_directive_loader, "bola");
will_return(__wrap_blogc_directive_loader, "chunda");
will_return(__wrap_blogc_directive_loader, 0);
html = blogc_content_parse(