Skip to content

Commit

Permalink
Merge pull request #51 from apple/QuietMisdreavus/gfm.11
Browse files Browse the repository at this point in the history
merge in changes from cmark-gfm 0.29.0.gfm.11
  • Loading branch information
QuietMisdreavus authored Apr 28, 2023
2 parents 86aeb49 + 6376383 commit 5ccf7dc
Show file tree
Hide file tree
Showing 27 changed files with 406 additions and 224 deletions.
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
13 changes: 2 additions & 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 "cmark-gfm"
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 @@ -51,6 +47,7 @@ if (CMARK_STATIC)

set_target_properties(${STATICLIBRARY} PROPERTIES
COMPILE_FLAGS "-DCMARK_GFM_STATIC_DEFINE -DCMARK_GFM_EXTENSIONS_STATIC_DEFINE"
DEFINE_SYMBOL "cmark-gfm"
POSITION_INDEPENDENT_CODE ON)

if (MSVC)
Expand All @@ -63,11 +60,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 +76,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
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.

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

0 comments on commit 5ccf7dc

Please sign in to comment.