diff --git a/lib/gollum-lib/filter/tags.rb b/lib/gollum-lib/filter/tags.rb index 0808701e..978620ea 100644 --- a/lib/gollum-lib/filter/tags.rb +++ b/lib/gollum-lib/filter/tags.rb @@ -120,8 +120,9 @@ def parse_tag_parts(tag) def process_include_tag(tag) len = INCLUDE_TAG.length return html_error('Cannot process include directive: no page name given') if tag.length <= len - page_name = tag[len..-1] - resolved_page_name = ::File.join(@markup.dir, page_name) + page_path = Pathname.new(tag[len..-1]) + resolved_page = page_path.relative? ? (Pathname.new(@markup.dir) + page_path) : page_path + resolved_page_name = resolved_page.cleanpath.to_s if @markup.include_levels > 0 page = find_page_or_file_from_path(resolved_page_name) if page diff --git a/test/test_markup.rb b/test/test_markup.rb index 8180a9d8..693b56c1 100644 --- a/test/test_markup.rb +++ b/test/test_markup.rb @@ -578,6 +578,13 @@ assert_html_equal("
hello
<java
script>alert(99);
", page1.formatted_data) end + test "include directive with absolute path from subdir" do + @wiki.write_page("/subdir/page1", :textile, "hello\n[[include:/a/very/long/path/to/page2]]\n", commit_details) + @wiki.write_page("/a/very/long/path/to/page2", :textile, "success", commit_details) + page1 = @wiki.page("/subdir/page1") + assert_html_equal("hello
success
", page1.formatted_data) + end + test "include directive with very long absolute path and relative include" do @wiki.write_page("page1", :textile, "hello\n[[include:/a/very/long/path/to/page2]]\n", commit_details) @wiki.write_page("/a/very/long/path/to/page2", :textile, "goodbye\n[[include:object]]", commit_details)