From 6327c111393484857731a25050226f6b36053de8 Mon Sep 17 00:00:00 2001 From: Kian-Meng Ang Date: Sun, 2 Nov 2025 22:45:16 +0800 Subject: [PATCH 1/2] chore: fix test errors for OTP 27/28 --- test/issue_71_test.exs | 18 ++++++++--------- test/sweet_xml_stream_test.exs | 36 ++++++++++++++++++++++------------ 2 files changed, 32 insertions(+), 22 deletions(-) diff --git a/test/issue_71_test.exs b/test/issue_71_test.exs index f3627ab..47ec736 100644 --- a/test/issue_71_test.exs +++ b/test/issue_71_test.exs @@ -4,31 +4,29 @@ defmodule Issue71Test do test "raise on reading /etc/passwd with dtd: :none" do sneaky_xml = File.read!("./test/files/xxe.xml") - assert {:fatal, {{:error_fetching_DTD, {_, _}}, _file, _line, _col}} = + assert {:fatal, {{:error, :entities_not_allowed}, _file, _line, _col}} = catch_exit(SweetXml.parse(sneaky_xml, dtd: :none, quiet: true)) end test "raise on reading /etc/passwd with dtd: :internal_only" do sneaky_xml = File.read!("./test/files/xxe.xml") - assert {:fatal, {{:error_fetching_DTD, {_, _}}, _file, _line, _col}} = + assert {:fatal, {{:error, :entities_not_allowed}, _file, _line, _col}} = catch_exit(SweetXml.parse(sneaky_xml, dtd: :internal_only, quiet: true)) end test "raise on reading /etc/passwd with dtd: [only: :banana]" do sneaky_xml = File.read!("./test/files/xxe.xml") - assert_raise RuntimeError, fn -> - SweetXml.parse(sneaky_xml, dtd: [only: :banana]) - end + assert {:fatal, {{:error, :entities_not_allowed}, _file, _line, _col}} = + catch_exit(SweetXml.parse(sneaky_xml, dtd: [only: :banana])) end test "raise on billion_laugh.xml with dtd: :none" do dangerous_xml = File.read!("./test/files/billion_laugh.xml") - assert_raise RuntimeError, fn -> - SweetXml.parse(dangerous_xml, dtd: :none) - end + assert {:fatal, {{:error, :entities_not_allowed}, _file, _line, _col}} = + catch_exit(SweetXml.parse(dangerous_xml, dtd: :none)) end test "stream: raise on reading /etc/passwd with dtd: :none" do @@ -41,7 +39,7 @@ defmodule Issue71Test do Stream.run(SweetXml.stream_tags(sneaky_xml, :banana, dtd: :none, quiet: true)) end) - assert_receive {:EXIT, ^pid, {:fatal, {{:error_fetching_DTD, {_, _}}, _file, _line, _col}}} + assert_receive {:EXIT, ^pid, {:fatal, {{:error, :entities_not_allowed}, _, _, _}}} end test "stream: raise on billion_laugh.xml with dtd: :none" do @@ -54,6 +52,6 @@ defmodule Issue71Test do Stream.run(SweetXml.stream_tags(dangerous_xml, :banana, dtd: :none, quiet: true)) end) - assert_receive {:EXIT, ^pid, {%RuntimeError{}, _stacktrace}} + assert_receive {:EXIT, ^pid, {:fatal, {{:error, :entities_not_allowed}, _, _, _}}} end end diff --git a/test/sweet_xml_stream_test.exs b/test/sweet_xml_stream_test.exs index 4220f8a..ff9825a 100644 --- a/test/sweet_xml_stream_test.exs +++ b/test/sweet_xml_stream_test.exs @@ -122,20 +122,32 @@ defmodule SweetXmlStreamTest do end test "DTD error" do - assert_raise SweetXml.DTDError, "DTD not allowed: lol1", fn -> - "test/files/billion_laugh.xml" - |> File.stream!() - |> SweetXml.stream_tags!(:banana, dtd: :none, quiet: true) - |> Stream.run() - end + Process.flag(:trap_exit, true) + + pid = + spawn_link(fn -> + "test/files/billion_laugh.xml" + |> File.stream!() + |> SweetXml.stream_tags!(:banana, dtd: :none, quiet: true) + |> Stream.run() + end) + + assert_receive {:EXIT, ^pid, reason} + assert match?({%SweetXml.XmerlFatal{reason: {:error, :entities_not_allowed}}, _}, reason) end test "internal only" do - assert_raise SweetXml.DTDError, "no external entity allowed", fn -> - "test/files/xxe.xml" - |> File.stream!() - |> SweetXml.stream_tags!(:result, dtd: :internal_only) - |> Stream.run() - end + Process.flag(:trap_exit, true) + + pid = + spawn_link(fn -> + "test/files/xxe.xml" + |> File.stream!() + |> SweetXml.stream_tags!(:result, dtd: :internal_only) + |> Stream.run() + end) + + assert_receive {:EXIT, ^pid, reason} + assert match?({%SweetXml.XmerlFatal{reason: {:error, :entities_not_allowed}}, _}, reason) end end From a82e0fc358c71601ae5b9cb70ff75bcbfd206778 Mon Sep 17 00:00:00 2001 From: Krapaince Date: Mon, 2 Mar 2026 14:31:56 +0100 Subject: [PATCH 2/2] ci: remove Elixir/OTP couple which reached EOL OTP 26 nearly reached EOL and OTP 29-rc1 was released one month ago. Keeping the support for OTP 26, requires more maintenance which will need to be removed in a few weeks. --- .github/workflows/ci.yml | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7f66862..ea5729e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -16,12 +16,8 @@ jobs: fail-fast: false matrix: include: - - elixir: "1.12" - otp: "24" - - elixir: "1.16" - otp: "25" - elixir: "1.17" - otp: "26" + otp: "27" - elixir: "1.18" otp: "27" - elixir: "1.19"