Skip to content

Commit b6e7b57

Browse files
committed
Sanitize paths from .rdoc_options at load time
1 parent d3ce87e commit b6e7b57

File tree

2 files changed

+21
-3
lines changed

2 files changed

+21
-3
lines changed

lib/rdoc/options.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -304,14 +304,15 @@ def init_with map # :nodoc:
304304
@main_page = map['main_page']
305305
@markup = map['markup']
306306
@op_dir = map['op_dir']
307-
@rdoc_include = map['rdoc_include']
308307
@show_hash = map['show_hash']
309-
@static_path = map['static_path']
310308
@tab_width = map['tab_width']
311309
@template_dir = map['template_dir']
312310
@title = map['title']
313311
@visibility = map['visibility']
314312
@webcvs = map['webcvs']
313+
314+
@rdoc_include = sanitize_path map['rdoc_include']
315+
@static_path = sanitize_path map['static_path']
315316
end
316317

317318
def yaml_initialize tag, map # :nodoc:

test/test_rdoc_options.rb

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,24 @@ def test_init_with_encoding
138138

139139
options = YAML.load YAML.dump @options
140140

141-
assert_equal Encoding::IBM437, @options.encoding
141+
assert_equal Encoding::IBM437, options.encoding
142+
end
143+
144+
def test_init_with_trim_paths
145+
RDoc.load_yaml
146+
147+
yaml = <<-YAML
148+
--- !ruby/object:RDoc::Options
149+
static_path:
150+
- /etc
151+
rdoc_include:
152+
- /etc
153+
YAML
154+
155+
options = YAML.load yaml
156+
157+
assert_empty options.rdoc_include
158+
assert_empty options.static_path
142159
end
143160

144161
def test_parse_copy_files_file_relative

0 commit comments

Comments
 (0)