Skip to content

Commit

Permalink
Don't attempt parsing code blocks that don't look like modules (#1662)
Browse files Browse the repository at this point in the history
  • Loading branch information
wojtekmach committed Feb 16, 2023
1 parent 486dce4 commit d00110f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/ex_doc/language/elixir.ex
Original file line number Diff line number Diff line change
Expand Up @@ -611,10 +611,14 @@ defmodule ExDoc.Language.Elixir do
end

defp parse_module(<<first>> <> _ = string, _mode) when first in ?A..?Z do
do_parse_module(string)
if string =~ ~r/^[A-Za-z0-9_.]+$/ do
do_parse_module(string)
else
:error
end
end

defp parse_module(<<?:>> <> _ = string, :custom_link) do
defp parse_module(":" <> _ = string, :custom_link) do
do_parse_module(string)
end

Expand Down
2 changes: 2 additions & 0 deletions test/ex_doc/language/elixir_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,8 @@ defmodule ExDoc.Language.ElixirTest do
assert_unchanged(~m"`Unknown`")

assert_unchanged(~m"[Blank](about:blank)")

assert_unchanged(~m"`FOR UPDATE OF ? SKIP LOCKED`")
end

## Helpers
Expand Down

0 comments on commit d00110f

Please sign in to comment.