diff --git a/lib/drab/live.ex b/lib/drab/live.ex index a4d1f4b..c97bd26 100644 --- a/lib/drab/live.ex +++ b/lib/drab/live.ex @@ -750,7 +750,8 @@ defmodule Drab.Live do end defp update_html_js(html, ampere, tag) do - case Floki.find(html, "[drab-ampere='#{ampere}']") do + {:ok, document} = Floki.parse_document(html) + case Floki.find(document, "[drab-ampere='#{ampere}']") do [{_, _, value}] -> new_value = Floki.raw_html(value, encode: false) @@ -803,8 +804,9 @@ defmodule Drab.Live do defp update_csrf_token(html, nil), do: html defp update_csrf_token(html, csrf) do - html - |> Floki.parse() + {:ok, document} = Floki.parse_document(html) + + document |> Floki.attr("input[name='_csrf_token']", "value", fn _ -> csrf end) |> Floki.attr("button[data-csrf]", "data-csrf", fn _ -> csrf end) |> Floki.attr("a[data-csrf]", "data-csrf", fn _ -> csrf end) diff --git a/mix.exs b/mix.exs index 311882f..d0e1d08 100644 --- a/mix.exs +++ b/mix.exs @@ -60,7 +60,7 @@ defmodule Drab.Mixfile do {:hound, "~> 1.0", only: [:dev, :test]}, {:inch_ex, "~> 1.0", only: [:docs], runtime: false}, {:deppie, "~> 1.0"}, - {:floki, ">= 0.20.2"}, + {:floki, ">= 0.27.0"}, {:dialyxir, "~> 1.0.0-rc.2", only: [:dev, :test], runtime: false}, # {:credo, "~> 0.9.3", only: [:dev, :test], runtime: false}, {:jason, "~> 1.0"}