Browse Source

encode special chars in xml attributes

danilo silva 3 years ago
parent
commit
64de0b9a88
3 changed files with 4 additions and 2 deletions
  1. 2 2
      lib/podcast_feed_web/templates/feed/feed.xml.eex
  2. 1 0
      mix.exs
  3. 1 0
      mix.lock

+ 2 - 2
lib/podcast_feed_web/templates/feed/feed.xml.eex

@@ -15,8 +15,8 @@
       <itunes:name><![CDATA[<%= @podcast.owner.name %>]]></itunes:name>
       <itunes:email><![CDATA[<%= @podcast.owner.email %>]]></itunes:email>
     </itunes:owner>
-    <itunes:category text="<%= @podcast.category %>">
-      <itunes:category text="<%= @podcast.category %>" />
+    <itunes:category text="<%= HtmlEntities.encode(@podcast.category) %>">
+      <itunes:category text="<%= HtmlEntities.encode(@podcast.category) %>" />
     </itunes:category>
     <itunes:keywords><%= @podcast.keywords |> Enum.join(", ") %></itunes:keywords>
     <itunes:explicit><![CDATA[<%= @podcast.explicit %>]]></itunes:explicit>

+ 1 - 0
mix.exs

@@ -47,6 +47,7 @@ defmodule PodcastFeed.MixProject do
       {:elixir_xml_to_map, "~> 1.0"},
       {:calendar, "~> 1.0.0"},
       {:hackney, "~> 1.15"},
+      {:html_entities, "~> 0.3"},
     ] ++ deps_dev() ++ deps_release()
   end
 

+ 1 - 0
mix.lock

@@ -15,6 +15,7 @@
   "file_system": {:hex, :file_system, "0.2.8", "f632bd287927a1eed2b718f22af727c5aeaccc9a98d8c2bd7bff709e851dc986", [:mix], [], "hexpm", "97a3b6f8d63ef53bd0113070102db2ce05352ecf0d25390eb8d747c2bde98bca"},
   "gettext": {:hex, :gettext, "0.18.0", "406d6b9e0e3278162c2ae1de0a60270452c553536772167e2d701f028116f870", [:mix], [], "hexpm", "c3f850be6367ebe1a08616c2158affe4a23231c70391050bf359d5f92f66a571"},
   "hackney": {:hex, :hackney, "1.15.2", "07e33c794f8f8964ee86cebec1a8ed88db5070e52e904b8f12209773c1036085", [:rebar3], [{:certifi, "2.5.1", [hex: :certifi, repo: "hexpm", optional: false]}, {:idna, "6.0.0", [hex: :idna, repo: "hexpm", optional: false]}, {:metrics, "1.0.1", [hex: :metrics, repo: "hexpm", optional: false]}, {:mimerl, "~>1.1", [hex: :mimerl, repo: "hexpm", optional: false]}, {:ssl_verify_fun, "1.1.5", [hex: :ssl_verify_fun, repo: "hexpm", optional: false]}], "hexpm", "e0100f8ef7d1124222c11ad362c857d3df7cb5f4204054f9f0f4a728666591fc"},
+  "html_entities": {:hex, :html_entities, "0.5.1", "1c9715058b42c35a2ab65edc5b36d0ea66dd083767bef6e3edb57870ef556549", [:mix], [], "hexpm", "30efab070904eb897ff05cd52fa61c1025d7f8ef3a9ca250bc4e6513d16c32de"},
   "idna": {:hex, :idna, "6.0.0", "689c46cbcdf3524c44d5f3dde8001f364cd7608a99556d8fbd8239a5798d4c10", [:rebar3], [{:unicode_util_compat, "0.4.1", [hex: :unicode_util_compat, repo: "hexpm", optional: false]}], "hexpm", "4bdd305eb64e18b0273864920695cb18d7a2021f31a11b9c5fbcd9a253f936e2"},
   "jason": {:hex, :jason, "1.2.1", "12b22825e22f468c02eb3e4b9985f3d0cb8dc40b9bd704730efa11abd2708c44", [:mix], [{:decimal, "~> 1.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "b659b8571deedf60f79c5a608e15414085fa141344e2716fbd6988a084b5f993"},
   "metrics": {:hex, :metrics, "1.0.1", "25f094dea2cda98213cecc3aeff09e940299d950904393b2a29d191c346a8486", [:rebar3], [], "hexpm", "69b09adddc4f74a40716ae54d140f93beb0fb8978d8636eaded0c31b6f099f16"},