Skip to content
New issue

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

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

Already on GitHub? # to your account

[1.4.40] Parser crash on EarmarkParser.as_ast("\\[{:}") #154

Closed
dominicletz opened this issue Jul 8, 2024 · 2 comments
Closed

[1.4.40] Parser crash on EarmarkParser.as_ast("\\[{:}") #154

dominicletz opened this issue Jul 8, 2024 · 2 comments
Assignees
Labels
bug Something isn't working High Priority

Comments

@dominicletz
Copy link

Using the EarmarkParser on the invalid md string "\\[{:}" causes a crash rather than returning an error. This is an issue for my use case where I'm using md-files to take notes and sometimes these notes contain ughly strings such as partial code fragments, backtraces and such. When finding that the parser would crash on one of my files I was able to reduce it to this minimal string causing the crash.

I don't understand the relationship between Earmark and EarmarkParser, so I've reported this issue there too: pragdave/earmark#494

iex(2)> EarmarkParser.as_ast("\\[{:}")
** (FunctionClauseError) no function clause matching in EarmarkParser.Helpers.AstHelpers.augment_tag_with_ial/2    
    
    The following arguments were given to EarmarkParser.Helpers.AstHelpers.augment_tag_with_ial/2:
    
        # 1
        ["["]
    
        # 2
        %{}
    
    Attempted function clauses (showing 2 out of 2):
    
        def augment_tag_with_ial([{t, a, c, m} | tags], atts)
        def augment_tag_with_ial([], _atts)
    
    (earmark_parser 1.4.40) lib/earmark_parser/helpers/ast_helpers.ex:29: EarmarkParser.Helpers.AstHelpers.augment_tag_with_ial/2
    (earmark_parser 1.4.40) lib/earmark_parser/ast/inline.ex:273: EarmarkParser.Ast.Inline.converter_for_inline_ial/1
    (elixir 1.17.0) lib/enum.ex:4343: Enum.find_value_list/3
    (earmark_parser 1.4.40) lib/earmark_parser/ast/inline.ex:38: EarmarkParser.Ast.Inline._convert/4
    (earmark_parser 1.4.40) lib/earmark_parser/ast_renderer.ex:32: EarmarkParser.AstRenderer.render_block/3
    (earmark_parser 1.4.40) lib/earmark_parser/ast_renderer.ex:23: EarmarkParser.AstRenderer._render/3
    (earmark_parser 1.4.40) lib/earmark_parser.ex:622: EarmarkParser.as_ast/2
    iex:2: (file)
@RobertDober
Copy link
Owner

Maybe the best way to put it:

There is no relationship anymore. They have been severed, Earmark is responsible for its own parser now.

That said this is a serious bug which needs to be fixed in both projects I will report it to Earmarkas well.

@RobertDober
Copy link
Owner

I just released v1.4.41 which contains the fix

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Something isn't working High Priority
Projects
None yet
Development

No branches or pull requests

2 participants