Skip to content

Commit b3cd9e2

Browse files
committed
Fix crash on HTML comments in incoming messages
1 parent c5df69a commit b3cd9e2

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

lib/format/matrix2irc.ex

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ defmodule M51.Format.Matrix2Irc do
3333
end
3434
end
3535

36+
def transform({:comment, _comment}, _state) do
37+
""
38+
end
39+
3640
def transform({"a", attributes, children}, state) do
3741
case attributes |> Map.new() |> Map.get("href") do
3842
nil ->

test/format/common_test.exs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,4 +335,8 @@ defmodule M51.FormatTest do
335335
assert M51.Format.matrix2irc("join <a href=\"https://matrix.to/#/%23\">oh no</a>") ==
336336
"join oh no <https://matrix.to/#/%23\>"
337337
end
338+
339+
test "HTML comment" do
340+
assert M51.Format.matrix2irc("foo <!-- bar --> baz") == "foo baz"
341+
end
338342
end

0 commit comments

Comments
 (0)