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

Fixes #154 #156

Merged
merged 1 commit into from
Jul 9, 2024
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 lib/earmark_parser/ast/inline.ex
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ defmodule EarmarkParser.Ast.Inline do
if match = Regex.run(@inline_ial, src) do
[match, ial] = match
{context1, ial_attrs} = parse_attrs(context, ial, lnb)
new_tags = augment_tag_with_ial(context.value, ial_attrs)
new_tags = augment_tag_with_ial(context.value, ial_attrs, match)
{behead(src, match), lnb, set_value(context1, new_tags), use_linky?}
end
end
Expand Down
9 changes: 6 additions & 3 deletions lib/earmark_parser/helpers/ast_helpers.ex
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,16 @@ defmodule EarmarkParser.Helpers.AstHelpers do
end

@doc false
def augment_tag_with_ial(tags, ial)
def augment_tag_with_ial([{t, a, c, m}|tags], atts) do
def augment_tag_with_ial(tags, ial, src)
def augment_tag_with_ial([{t, a, c, m}|tags], atts, _src) do
[{t, merge_attrs(a, atts), c, m}|tags]
end
def augment_tag_with_ial([], _atts) do
def augment_tag_with_ial([], _atts, _src) do
[]
end
def augment_tag_with_ial([any], _atts, src) do
[any <> src]
end

@doc false
def code_classes(language, prefix) do
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
defmodule Test.Acceptance.Regressions.I154pArserCrashSymbolicInputTest do
use ExUnit.Case

import Support.Helpers, only: [as_ast: 1]
import EarmarkAstDsl

test "this should not crash" do
ast = [ p("[{:}") ]
messages = []
assert as_ast("\\[{:}") == {:ok, ast, messages}
end

test "this does not crash" do
ast = [ p("[{:") ]
messages = []
assert as_ast("\\[{:") == {:ok, ast, messages}
end

test "nor does this" do
ast = [ p("[{:}") ]
messages = []
assert as_ast("[{:}") == {:ok, ast, messages}
end

test "nor this" do
ast = [{"p", [], [{"em", [], ["a"], %{}}], %{}}]
messages = []
assert as_ast("*a*{:}") == {:ok, ast, messages}

end
end
# SPDX-License-Identifier: Apache-2.0
Loading