Skip to content

Commit 26a96dd

Browse files
committed
Escape attributes
1 parent 4eed575 commit 26a96dd

File tree

5 files changed

+6
-6
lines changed

5 files changed

+6
-6
lines changed

lib/ex_doc/doc_ast.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ defmodule ExDoc.DocAST do
6262
end
6363

6464
defp ast_attributes_to_string(attrs) do
65-
Enum.map(attrs, fn {key, val} -> " #{key}=\"#{val}\"" end)
65+
Enum.map(attrs, fn {key, val} -> " #{key}=\"#{ExDoc.Utils.h(val)}\"" end)
6666
end
6767

6868
## parse markdown

lib/ex_doc/formatter/epub/templates/module_template.eex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
<%= for group <- module.docs_groups, key = text_to_id(group.title) do %>
2626
<section id="<%= key %>" class="details-list">
2727
<h1 class="section-heading"><%=h to_string(group.title) %></h1>
28-
<%= if doc = group.doc do %>
28+
<%= if doc = group.doc do %>
2929
<div class="group-description" id="group-description-<%= key %>">
3030
<%= render_doc(doc) %>
3131
</div>

lib/ex_doc/formatter/html/templates.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ defmodule ExDoc.Formatter.HTML.Templates do
4040
def module_type(%{type: :module}), do: ""
4141
def module_type(%{type: type}), do: "<small>#{type}</small>"
4242

43-
defp enc(binary), do: URI.encode(binary)
43+
defp enc(binary), do: ExDoc.Utils.h(URI.encode(binary))
4444

4545
@doc """
4646
Create a JS object which holds all the items displayed in the sidebar area

lib/ex_doc/formatter/html/templates/summary_template.eex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
<div class="summary-<%= text_to_id(name) %> summary">
22
<h2>
3-
<a href="#<%= text_to_id(name) %>"><%= name %></a>
3+
<a href="#<%=h text_to_id(name) %>"><%= name %></a>
44
</h2>
55
<%= for node <- nodes do %>
66
<div class="summary-row">
77
<div class="summary-signature">
88
<a href="#<%=enc node.id %>" data-no-tooltip="" translate="no"><%=h node.signature %></a>
99
<%= if deprecated = node.deprecated do %>
10-
<span class="deprecated" title="<%= h(deprecated) %>">deprecated</span>
10+
<span class="deprecated" title="<%=h deprecated %>">deprecated</span>
1111
<% end %>
1212
</div>
1313
<%= if doc = node.doc do %>

test/ex_doc/language/elixir_test.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ defmodule ExDoc.Language.ElixirTest do
128128
~s|<a href="https://hexdocs.pm/elixir/Kernel.html#+/2"><code class="inline">+/2</code></a>|
129129

130130
assert autolink_doc("`&/1`") ==
131-
~s|<a href="https://hexdocs.pm/elixir/Kernel.SpecialForms.html#&/1"><code class="inline">&amp;/1</code></a>|
131+
~s|<a href="https://hexdocs.pm/elixir/Kernel.SpecialForms.html#&amp;/1"><code class="inline">&amp;/1</code></a>|
132132

133133
assert autolink_doc("`for/1`") ==
134134
~s|<a href="https://hexdocs.pm/elixir/Kernel.SpecialForms.html#for/1"><code class="inline">for/1</code></a>|

0 commit comments

Comments
 (0)