Commit Graph

683 Commits

Author SHA1 Message Date
Martin Mitas
dec252d4be Bump version 0.5.1 and update CHANGELOG.md. 2024-01-21 10:39:06 +01:00
Martin Mitas
65957f5369 Limit number of table columns to prevent explosion of output...
with the input pattern in the form of geneated by this one-liner:

$ python3 -c 'N=1000; print("x|" * N + "\n" + "-|" * N + "\n" + "x\n" * N)'

Here the amount of HTML otput grows with N^2.
2024-01-19 22:42:56 +01:00
Martin Mitas
70b247cf7d md_analyze_permissive_autolink: Accept path ending with '/'.
Fixes #226.
2024-01-19 13:59:45 +01:00
Martin Mitas
bbb43fe098 Rename PUSH_MARK() to ADD_MARK().
This is to pevent confusion with opener stack operations.
2024-01-18 17:30:44 +01:00
Martin Mitáš
246e105dfb
Refactor mark chains. (#224)
* Rename MD_MARKCHAIN to MD_MARKSTACK to indicate its semantics much
  clearer.
* Simplify its implementation (single-linked list instead of
  double-linked one).
* Where it was reused (misused?) for other, unrelated stuff, with other
  semantics, it's now done explicitly. (i.e. got rid of
  TABLECELLBOUNDARIES).
* PTR_CHAIN still uses the stack (we don't care about order there), but
  it got separated from the array of ordinary opener stacks at least.
2024-01-18 17:22:54 +01:00
Martin Mitas
601ff05326 Fix handling new line at beginning/end of a code span.
Fixes #223.
2024-01-18 16:49:37 +01:00
Martin Mitas
c076698ab5 md_collect_marks: Get rid of helper vars line_beg, line_end. 2024-01-18 16:10:46 +01:00
Martin Mitas
23b1416866 pathological-tests.py: Fix output if a test unit ends with non-zero exit code. 2024-01-18 15:12:26 +01:00
Martin Mitas
087288312f md_rollback: Update outdated comment. 2024-01-18 13:39:48 +01:00
Martin Mitas
d40458b5b5 md_rollback: Simplify the function.
We assume the provided opener_index and closer_index do not cross
boundaries of already resolved ranges. Previously the function tried
deal with such situation but this code should not be needed, it was very
complex and, most importantly, broken anyway.
2024-01-18 12:39:36 +01:00
Martin Mitas
a08f6a05f1 Improve/fix latex math extension.
To mitigate false positives:

* We accept $ and $$ as a potential opener only if it's not preceded
  with alnum char.

* Similarly closer cannot be followed with alnum char.

* We now also match closer with last preceding pontential opener, not
  the first one. (And to avoid nesting, any previous openers are
  ignored.)

* Also revert an unintended change in 3fc207affa
  which allowed keeping nested resolved marks in it.
2024-01-18 12:29:31 +01:00
Martin Mitas
3fc207affa Handle e-mail autolinks in a safer way.
For standard e-mail autolinks <user@host> we internally transformed '<'
into '@' (permissive e-mail autolink) to unify handling of missing
"mailto:" needed into the destination attribute.

This is now not true anymore and we handle that specially.

It is actually what has bitten us in
https://oss-fuzz.com/testcase-detail/4815193402048512.

Even though this isn't the root cause of the issue, this change makes
the code safer and easier to understand.
2024-01-18 10:56:12 +01:00
Martin Mitas
4728cd981d md_analyze_tilde: Pop from chain tail like other emphasis.
The function incorrectly used header from the head, leading to wrong
result (incompatible with e.. GFM) but even worse to bad internal state
md_rollback() is then potentially unable to solve.

Fixes #222.
2024-01-17 16:04:14 +01:00
Martin Mitas
006611b9ab md_analyze_dollar: Call md_rollback() only when resolving.
Fixes #221.
2024-01-17 15:04:14 +01:00
Martin Mitas
2ba5e2c660 Make --replay-fuzz friendlier to work with in debugger.
We make effectively input zero-terminated so debugger doesn't attempt to
write more than what's really provided.
2024-01-17 14:48:57 +01:00
Martin Mitas
f45dd4420e Add regression test for #213.
As it's now possible to add tests with multiple cmdline options easily.
2024-01-17 02:58:12 +01:00
Martin Mitáš
d955c495ee
Rework permissive autolinks. (#220)
* We have now dedicated run over the inline marks for them.

 * We check more throughly whether it really looks as an URL or e-mail
   address. The old implementation recognized even heavily broken ones.

 * This allows us to be much more careful in order not to cross already
   resolved marks.

 * Share substantial parts of the code between all three types of the
   permissive autolinks (URL, WWW, e-mail).

 * Merge their tests into one file, spec-permissive-autolinks.txt.

 * Add one pathological case which triggered quadratic behavior in the
   old implementation.
2024-01-17 02:48:57 +01:00
Martin Mitas
a715b884ac Rename many files in test dir for better organization. 2024-01-16 19:05:52 +01:00
Martin Mitas
4b9e4d7cdd Move one more forgotten regression test to regressions.txt. 2024-01-16 19:05:52 +01:00
Martin Mitas
20cb74457b Merge branch 'test_opts' 2024-01-16 15:10:57 +01:00
Martin Mitas
6685df9c50 Move all regression tests into new tests/regressions.txt.
(And update scripts/run-tests.sh accordingly.)
2024-01-16 15:09:33 +01:00
Martin Mitas
74e5f7a9a7 Tests: Specify md2html command line options for each example as needed.
Previously the caller (or the script scripts/run_tests.sh) needed to
know what options to specify.
2024-01-16 14:56:09 +01:00
Martin Mitas
359406bfb2 Test: Add support for per-example command line options.
(We also removed direct call support into the library. It was inherited
from cmark as the testsuite was originally taken from there, but it
actually was never updated to work with MD4C.)
2024-01-16 14:45:00 +01:00
Martin Mitas
0ac9f35d06 md_analyze_marks: Skip analyzing marks if...
they fall into range of previously analyzed mark. That can happen if the
previous mark has been expanded. That typically happens for permissive
auto-links.

This fixes one case of pathologic input leading to quadratic behavior.
2024-01-16 11:36:13 +01:00
Martin Mitas
b6777d7812 Wiki-links extension: Search for '|' only outside resolved ranges. 2024-01-16 01:30:59 +01:00
Martin Mitas
afeece2981 Fix line indentation calculation when interrupting list...
due the "list item cannot begin with two blank lines" rule.
2024-01-15 23:03:21 +01:00
Martin Mitas
481230f418 Bump version to 0.5.0. 2024-01-15 08:34:21 +01:00
Martin Mitas
4b5dd10e4a README.md: Add imgui_md to Software using MD4C.
(And sort the items alphabetically.)
2024-01-13 15:04:31 +01:00
Martin Mitas
716da8b01b CHANGELOG.md: Fix typo. 2024-01-13 11:44:27 +01:00
Martin Mitas
cf1226ddee Update CHANGELOG.md. 2024-01-13 03:14:13 +01:00
Martin Mitas
7882942708 Fix some emphasis parsing issues.
* We incorrectly applied the infamous rule of three only to
   asterisk-encoded emphasis, it has to be applied to underscore as
   well.

 * We incorrectly applied the rule of three only if the opener
   and/or closer was inside a word. It has also to be applied if the
   mark is both preceded and followed by punctuation.

Fixes #217.
2024-01-13 03:11:29 +01:00
Martin Mitas
5592352fdb HTML declaration doesn't require whitespace before the closer.
Fixes #216.
2024-01-13 00:30:08 +01:00
Martin Mitas
7497ea92b3 Allow tabs after setext header underline.
Fixes #215.
2024-01-13 00:17:08 +01:00
Martin Mitas
2750d9fa3b Add tags <h2>...<h6> as triggers for HTML block type 6.
Fixes #214.
2024-01-13 00:05:38 +01:00
Martin Mitas
0d10b60b19 Move test/fuzz-input/ to test/fuzzers/seed-corpus/. 2024-01-12 22:44:31 +01:00
Martin Mitas
4a64fee2ee Bump copyright years. 2024-01-11 13:12:55 +01:00
Martin Mitas
5204c30d40 md_is_html_block_end_condition: Fix return value. 2024-01-11 12:41:40 +01:00
Martin Mitas
f32a861efa md_end_current_block: Fix EOL handling. 2024-01-11 12:21:02 +01:00
Martin Mitas
76abc636ad md_is_html_block_end_condition: Fix EOF handling. 2024-01-11 12:09:55 +01:00
Martin Mitas
4a7246de40 md_is_inline_link_spec: Fix EOL checking. 2024-01-11 11:56:19 +01:00
Martin Mitas
af96a3f4f7 ci-fuzz.yml: Reenable "Upload Sarif" step.
See https://github.com/google/oss-fuzz/issues/10915.
2024-01-11 10:57:02 +01:00
Martin Mitas
3e576b4938 Rename the fuzz test workflow. 2024-01-11 10:49:05 +01:00
Martin Mitas
407b107e0b ci-fuzz.yml: .yml cannot have multiple "if" in one step. 2024-01-11 10:42:27 +01:00
Martin Mitas
5933084293 ci-fuzz.yml: Disable step "Upload Sarif".
(It got in from the oss-fuzz's example cifuzz.yml, but IDK even what it
is so hopefully we can live without it.)
2024-01-11 10:39:52 +01:00
Martin Mitas
85b971a34d Try to fix ci-fuzz.yml by fixing indentation. 2024-01-11 10:01:00 +01:00
Martin Mitas
722cacad9d Try to fix ci-fuzz.yml by removing permissions {}.
cmark doesn't have that line either.
2024-01-11 09:56:07 +01:00
Martin Mitas
87d4f06349 Enable CI fuzzing via oss-fuzz project.
Should perform some initial 10 min fuzz testing on pull requests.
2024-01-11 09:50:58 +01:00
Martin Mitas
e25ea3d182 Update list of named entities. 2024-01-11 03:34:24 +01:00
Martin Mitas
35ca9b0bdb Wording improvements in README.md. 2024-01-11 01:09:35 +01:00
Martin Mitas
3209f9709a Update CHANGELOG.md. 2024-01-11 01:06:59 +01:00