File tree Expand file tree Collapse file tree 2 files changed +22
-1
lines changed
lib/rdoc/generator/template/darkfish Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Original file line number Diff line number Diff line change 17
17
main_page = @files . find { |f | f . full_name == @options . main_page } then %>
18
18
<%= main_page . description %>
19
19
<%- else -%>
20
- < p > This is the API documentation for <%= @title %> .
20
+ < p > This is the API documentation for <%= h @title %> .
21
21
<%- end -%>
22
22
</ main >
Original file line number Diff line number Diff line change @@ -248,6 +248,22 @@ def test_template_stylesheets
248
248
assert_include File . read ( 'index.html' ) , %Q[href="./#{ base } "]
249
249
end
250
250
251
+ def test_title
252
+ title = "RDoc Test" . freeze
253
+ @options . title = title
254
+ @g . generate
255
+
256
+ assert_main_title ( File . read ( 'index.html' ) , title )
257
+ end
258
+
259
+ def test_title_escape
260
+ title = %[<script>alert("RDoc")</script>] . freeze
261
+ @options . title = title
262
+ @g . generate
263
+
264
+ assert_main_title ( File . read ( 'index.html' ) , title )
265
+ end
266
+
251
267
##
252
268
# Asserts that +filename+ has a link count greater than 1 if hard links to
253
269
# @tmpdir are supported.
@@ -271,4 +287,9 @@ def assert_hard_link filename
271
287
"#{ filename } is not hard-linked"
272
288
end
273
289
290
+ def assert_main_title ( content , title )
291
+ title = CGI . escapeHTML ( title )
292
+ assert_equal ( title , content [ %r[<title>(.*?)<\/ title>]im , 1 ] )
293
+ assert_include ( content [ %r[<main\s [^<>]*+>\s *(.*?)</main>]im , 1 ] , title )
294
+ end
274
295
end
You can’t perform that action at this time.
0 commit comments