Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Un-revert #51 and fix Windows build errors #55

Merged
merged 2 commits into from
May 3, 2023
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
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ project(cmark-gfm)
set(PROJECT_VERSION_MAJOR 0)
set(PROJECT_VERSION_MINOR 29)
set(PROJECT_VERSION_PATCH 0)
set(PROJECT_VERSION_GFM 6)
set(PROJECT_VERSION_GFM 11)
set(PROJECT_VERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}.gfm.${PROJECT_VERSION_GFM})

include("FindAsan.cmake")
Expand Down
1 change: 1 addition & 0 deletions api_test/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1575,6 +1575,7 @@ int main() {
int retval;
test_batch_runner *runner = test_batch_runner_new();

cmark_enable_safety_checks(true);
version(runner);
constructor(runner);
accessors(runner);
Expand Down
41 changes: 41 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,44 @@
[0.29.0.gfm.11]

* Improved fixes for polynomial time complexity issues per
https://github.com/github/cmark-gfm/security/advisories/GHSA-66g8-4hjf-77xh
(#323, #324)
* Added fuzzing target for bracketed patterns (#318)
* Fixed bug in list numbering introduced in
763587e8775350b8cb4a2aa0f4cec3685aa96e8b (#322) which caused list numbers
to increment by 2
* Fixed strict prototype clang warning (#310)
* Fixed regression test (#312)
* Added additional output formats to quadratic fuzzer (#327)
* Fixed buffer overflow in fuzzing harness (#326)

Note: these changes may lead to minor changes in expected output on plaintext
rendering of list items. Notably, blank lines may no longer delineate the start
of a list when rendering to plaintext due to changes in how the tight list status
is calculated.

[0.29.0.gfm.10]

* Fixed polynomial time complexity issue per
https://github.com/github/cmark-gfm/security/advisories/GHSA-r8vr-c48j-fcc5
* Fixed polynomial time complexity issues per
https://github.com/github/cmark-gfm/security/advisories/GHSA-66g8-4hjf-77xh

Note: these changes remove redundant bold tag nesting which may result
in existing rendering tests failing, e.g. rendering "____bold____" to html
will no longer yield "<p><strong><strong>bold</strong></strong></p>".

[0.29.0.gfm.9]

* Cleanup: Use of a private header was cleaned up (#248)
* Cleanup: Man page was updated (#255)
* Cleanup: Warnings for -Wstrict-prototypes were cleaned up (#285)
* Cleanup: We avoid header duplication (#289)

* We now store positioning info for url_match (#201)
* We now expose cmark_parent_footnote_def for non-C renderers (#254)
* Footnote aria-label text now reference the specific footnote backref, and we include a data-footnote-backref-idx attribute so the label can be internationalized in a downstream filter (#307)

[0.29.0.gfm.8]

* We restored backwards compatibility by deprecating the `cmark_init_standard_node_flags()` requirement, which is now a noop (#305)
Expand Down
12 changes: 1 addition & 11 deletions extensions/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ include_directories(
${PROJECT_BINARY_DIR}/src
)

include (GenerateExportHeader)

include_directories(include ${CMAKE_CURRENT_BINARY_DIR})

set(CMAKE_C_FLAGS_PROFILE "${CMAKE_C_FLAGS_RELEASE} -pg")
Expand All @@ -29,6 +27,7 @@ if (CMARK_SHARED)

set_target_properties(${LIBRARY} PROPERTIES
OUTPUT_NAME "cmark-gfm-extensions"
DEFINE_SYMBOL "libcmark_gfm_EXPORTS"
SOVERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}.gfm.${PROJECT_VERSION_GFM}
VERSION ${PROJECT_VERSION})

Expand All @@ -38,9 +37,6 @@ if (CMARK_SHARED)
# Avoid name clash between PROGRAM and LIBRARY pdb files.
set_target_properties(${LIBRARY} PROPERTIES PDB_NAME cmark-gfm-extensions_dll)

generate_export_header(${LIBRARY}
BASE_NAME cmark-gfm-extensions)

list(APPEND CMARK_INSTALL ${LIBRARY})
target_link_libraries(${LIBRARY} libcmark-gfm)

Expand All @@ -63,11 +59,6 @@ if (CMARK_STATIC)
VERSION ${PROJECT_VERSION})
endif(MSVC)

if (NOT CMARK_SHARED)
generate_export_header(${STATICLIBRARY}
BASE_NAME cmark-gfm-extensions)
endif()

list(APPEND CMARK_INSTALL ${STATICLIBRARY})
endif()

Expand All @@ -84,7 +75,6 @@ install(TARGETS ${CMARK_INSTALL}
if (CMARK_SHARED OR CMARK_STATIC)
install(FILES
${CMAKE_CURRENT_SOURCE_DIR}/include/cmark-gfm-core-extensions.h
${CMAKE_CURRENT_SOURCE_DIR}/include/extensions-export.h
DESTINATION include
)

Expand Down
5 changes: 5 additions & 0 deletions extensions/autolink.c
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,11 @@ static cmark_node *url_match(cmark_parser *parser, cmark_node *parent,
cmark_node *text = cmark_node_new_with_mem(CMARK_NODE_TEXT, parser->mem);
text->as.literal = url;
cmark_node_append_child(node, text);

node->start_line = text->start_line = node->end_line = text->end_line = cmark_inline_parser_get_line(inline_parser);

node->start_column = text->start_column = max_rewind - rewind;
node->end_column = text->end_column = cmark_inline_parser_get_column(inline_parser) - 1;

return node;
}
Expand Down
1 change: 1 addition & 0 deletions extensions/core-extensions.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ static void register_plugins(void) {
cmark_register_plugin(core_extensions_registration);
}

CMARK_GFM_EXPORT
void cmark_gfm_core_extensions_ensure_registered(void) {
CMARK_RUN_ONCE(registered, register_plugins);
}
30 changes: 15 additions & 15 deletions extensions/include/cmark-gfm-core-extensions.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,40 +6,40 @@ extern "C" {
#endif

#include "cmark-gfm-extension_api.h"
#include "extensions-export.h"
#include "cmark-gfm_config.h" // for bool
#include "export.h"
#include <stdbool.h>
#include <stdint.h>

CMARK_GFM_EXTENSIONS_EXPORT
CMARK_GFM_EXPORT
void cmark_gfm_core_extensions_ensure_registered(void);

CMARK_GFM_EXTENSIONS_EXPORT
CMARK_GFM_EXPORT
uint16_t cmark_gfm_extensions_get_table_columns(cmark_node *node);

/** Sets the number of columns for the table, returning 1 on success and 0 on error.
*/
CMARK_GFM_EXTENSIONS_EXPORT
CMARK_GFM_EXPORT
int cmark_gfm_extensions_set_table_columns(cmark_node *node, uint16_t n_columns);

CMARK_GFM_EXTENSIONS_EXPORT
CMARK_GFM_EXPORT
uint8_t *cmark_gfm_extensions_get_table_alignments(cmark_node *node);

/** Sets the alignments for the table, returning 1 on success and 0 on error.
*/
CMARK_GFM_EXTENSIONS_EXPORT
CMARK_GFM_EXPORT
int cmark_gfm_extensions_set_table_alignments(cmark_node *node, uint16_t ncols, uint8_t *alignments);

CMARK_GFM_EXTENSIONS_EXPORT
CMARK_GFM_EXPORT
int cmark_gfm_extensions_get_table_row_is_header(cmark_node *node);

/** Sets the column span for the table cell, returning 1 on success and 0 on error.
*/
CMARK_GFM_EXTENSIONS_EXPORT
CMARK_GFM_EXPORT
int cmark_gfm_extensions_set_table_cell_colspan(cmark_node *node, unsigned colspan);

/** Sets the row span for the table cell, returning 1 on success and 0 on error.
*/
CMARK_GFM_EXTENSIONS_EXPORT
CMARK_GFM_EXPORT
int cmark_gfm_extensions_set_table_cell_rowspan(cmark_node *node, unsigned rowspan);

/**
Expand All @@ -50,7 +50,7 @@ int cmark_gfm_extensions_set_table_cell_rowspan(cmark_node *node, unsigned rowsp

Column span is only parsed when \c CMARK_OPT_TABLE_SPANS is set.
*/
CMARK_GFM_EXTENSIONS_EXPORT
CMARK_GFM_EXPORT
unsigned cmark_gfm_extensions_get_table_cell_colspan(cmark_node *node);

/**
Expand All @@ -61,22 +61,22 @@ unsigned cmark_gfm_extensions_get_table_cell_colspan(cmark_node *node);

Row span is only parsed when \c CMARK_OPT_TABLE_SPANS is set.
*/
CMARK_GFM_EXTENSIONS_EXPORT
CMARK_GFM_EXPORT
unsigned cmark_gfm_extensions_get_table_cell_rowspan(cmark_node *node);

/** Sets whether the node is a table header row, returning 1 on success and 0 on error.
*/
CMARK_GFM_EXTENSIONS_EXPORT
CMARK_GFM_EXPORT
int cmark_gfm_extensions_set_table_row_is_header(cmark_node *node, int is_header);

CMARK_GFM_EXTENSIONS_EXPORT
CMARK_GFM_EXPORT
bool cmark_gfm_extensions_get_tasklist_item_checked(cmark_node *node);
/* For backwards compatibility */
#define cmark_gfm_extensions_tasklist_is_checked cmark_gfm_extensions_get_tasklist_item_checked

/** Sets whether a tasklist item is "checked" (completed), returning 1 on success and 0 on error.
*/
CMARK_GFM_EXTENSIONS_EXPORT
CMARK_GFM_EXPORT
int cmark_gfm_extensions_set_tasklist_item_checked(cmark_node *node, bool is_checked);

#ifdef __cplusplus
Expand Down
60 changes: 0 additions & 60 deletions extensions/include/extensions-export.h

This file was deleted.

12 changes: 11 additions & 1 deletion extensions/table.c
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ static cmark_node *try_opening_table_header(cmark_syntax_extension *self,
if (!marker_row) {
return parent_container;
}

assert(marker_row);

cmark_arena_push();
Expand Down Expand Up @@ -1029,30 +1029,35 @@ cmark_syntax_extension *create_table_extension(void) {
return self;
}

CMARK_GFM_EXPORT
uint16_t cmark_gfm_extensions_get_table_columns(cmark_node *node) {
if (node->type != CMARK_NODE_TABLE)
return 0;

return ((node_table *)node->as.opaque)->n_columns;
}

CMARK_GFM_EXPORT
uint8_t *cmark_gfm_extensions_get_table_alignments(cmark_node *node) {
if (node->type != CMARK_NODE_TABLE)
return 0;

return ((node_table *)node->as.opaque)->alignments;
}

CMARK_GFM_EXPORT
int cmark_gfm_extensions_set_table_columns(cmark_node *node, uint16_t n_columns) {
return set_n_table_columns(node, n_columns);
}

CMARK_GFM_EXPORT
int cmark_gfm_extensions_set_table_alignments(cmark_node *node, uint16_t ncols, uint8_t *alignments) {
uint8_t *a = (uint8_t *)cmark_node_mem(node)->calloc(1, ncols);
memcpy(a, alignments, ncols);
return set_table_alignments(node, a);
}

CMARK_GFM_EXPORT
int cmark_gfm_extensions_get_table_row_is_header(cmark_node *node)
{
if (!node || node->type != CMARK_NODE_TABLE_ROW)
Expand All @@ -1061,6 +1066,7 @@ int cmark_gfm_extensions_get_table_row_is_header(cmark_node *node)
return ((node_table_row *)node->as.opaque)->is_header;
}

CMARK_GFM_EXPORT
int cmark_gfm_extensions_set_table_row_is_header(cmark_node *node, int is_header)
{
if (!node || node->type != CMARK_NODE_TABLE_ROW)
Expand All @@ -1070,21 +1076,25 @@ int cmark_gfm_extensions_set_table_row_is_header(cmark_node *node, int is_header
return 1;
}

CMARK_GFM_EXPORT
unsigned cmark_gfm_extensions_get_table_cell_colspan(cmark_node *node)
{
return get_cell_colspan(node);
}

CMARK_GFM_EXPORT
unsigned cmark_gfm_extensions_get_table_cell_rowspan(cmark_node *node)
{
return get_cell_rowspan(node);
}

CMARK_GFM_EXPORT
int cmark_gfm_extensions_set_table_cell_colspan(cmark_node *node, unsigned colspan)
{
return set_cell_colspan(node, colspan);
}

CMARK_GFM_EXPORT
int cmark_gfm_extensions_set_table_cell_rowspan(cmark_node *node, unsigned rowspan)
{
return set_cell_rowspan(node, rowspan);
Expand Down
2 changes: 2 additions & 0 deletions extensions/tasklist.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ static const char *get_type_string(cmark_syntax_extension *extension, cmark_node


// Return 1 if state was set, 0 otherwise
CMARK_GFM_EXPORT
int cmark_gfm_extensions_set_tasklist_item_checked(cmark_node *node, bool is_checked) {
// The node has to exist, and be an extension, and actually be the right type in order to get the value.
if (!node || !node->extension || strcmp(cmark_node_get_type_string(node), TYPE_STRING))
Expand All @@ -27,6 +28,7 @@ int cmark_gfm_extensions_set_tasklist_item_checked(cmark_node *node, bool is_che
return 1;
}

CMARK_GFM_EXPORT
bool cmark_gfm_extensions_get_tasklist_item_checked(cmark_node *node) {
if (!node || !node->extension || strcmp(cmark_node_get_type_string(node), TYPE_STRING))
return false;
Expand Down
1 change: 1 addition & 0 deletions fuzz/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ macro(fuzzer name)
endmacro()

fuzzer(fuzz_quadratic)
fuzzer(fuzz_quadratic_brackets)
7 changes: 6 additions & 1 deletion fuzz/fuzz_quadratic.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,13 @@ int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {

cmark_parser_feed(parser, markdown, markdown_size);
cmark_node *doc = cmark_parser_finish(parser);

free(cmark_render_html(doc, fuzz_config.options, NULL));
free(cmark_render_xml(doc, fuzz_config.options));
free(cmark_render_man(doc, fuzz_config.options, 80));
free(cmark_render_commonmark(doc, fuzz_config.options, 80));
free(cmark_render_plaintext(doc, fuzz_config.options, 80));
free(cmark_render_latex(doc, fuzz_config.options, 80));

cmark_node_free(doc);
cmark_parser_free(parser);
Expand Down
Loading