Skip to content

Commit

Permalink
Do not crash on invalid line type
Browse files Browse the repository at this point in the history
  • Loading branch information
gBillal committed Dec 22, 2024
1 parent 5f112c0 commit 9f7cfa0
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/ex_sdp/parser.ex
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,8 @@ defmodule ExSDP.Parser do
end
end

defp parse_line(_lines, _session), do: {:error, :invalid_line}

defp format_error(["m=" <> _rest = line | rest], reason) do
attributes =
rest
Expand Down
13 changes: 13 additions & 0 deletions test/sdp_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,19 @@ defmodule ExSDPTest do

assert {:error, {:invalid_bandwidth, "b=X-YZ:256"}} == assert(ExSDP.parse(input))
end

test "returns an error on invalid line" do
input =
"""
v=0
o=jdoe 2890844526 2890842807 IN IP4 10.47.16.5
l=invalid line
s=Very fancy session name
"""
|> String.replace("\n", "\r\n")

assert {:error, {:invalid_line, "l=invalid line"}} = ExSDP.parse(input)
end
end

describe "Parser parse!/1" do
Expand Down

0 comments on commit 9f7cfa0

Please sign in to comment.