Skip to content

Commit

Permalink
raw_html treats the content of title tags as plain text
Browse files Browse the repository at this point in the history
  • Loading branch information
aymanosman committed Mar 13, 2024
1 parent 3d5adab commit 0b6c87f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/floki/raw_html.ex
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ defmodule Floki.RawHTML do
case type do
"script" -> @no_encoder
"style" -> @no_encoder
"title" -> @no_encoder
_ -> encoder
end

Expand Down
6 changes: 6 additions & 0 deletions test/floki_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -563,6 +563,12 @@ defmodule FlokiTest do
assert recombined
end

test "raw_html treats the contents of title tags as plain text" do

Check failure on line 566 in test/floki_test.exs

View workflow job for this annotation

GitHub Actions / Elixir 1.16 / OTP 26.2 with fast_html

test raw_html treats the contents of title tags as plain text (FlokiTest)

Check failure on line 566 in test/floki_test.exs

View workflow job for this annotation

GitHub Actions / Elixir 1.16 / OTP 26.2 with html5ever

test raw_html treats the contents of title tags as plain text (FlokiTest)

Check failure on line 566 in test/floki_test.exs

View workflow job for this annotation

GitHub Actions / Elixir 1.16 / OTP 25.3 with fast_html

test raw_html treats the contents of title tags as plain text (FlokiTest)

Check failure on line 566 in test/floki_test.exs

View workflow job for this annotation

GitHub Actions / Elixir 1.16 / OTP 25.3 with html5ever

test raw_html treats the contents of title tags as plain text (FlokiTest)

Check failure on line 566 in test/floki_test.exs

View workflow job for this annotation

GitHub Actions / Elixir 1.13 / OTP 22.3 with fast_html

test raw_html treats the contents of title tags as plain text (FlokiTest)

Check failure on line 566 in test/floki_test.exs

View workflow job for this annotation

GitHub Actions / Elixir 1.13 / OTP 22.3 with html5ever

test raw_html treats the contents of title tags as plain text (FlokiTest)
html_string = ~s(<title> <b> bold </b> text </title>)
parsed = Floki.parse_document!(html_string)
assert ^html_string = Floki.raw_html(parsed)
end

# Floki.find/2 - Classes

test "find elements with a given class" do
Expand Down

0 comments on commit 0b6c87f

Please sign in to comment.