Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Léo-Paul Géneau
gitlab-ce
Commits
31e59219
Commit
31e59219
authored
7 years ago
by
Nick Thomas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix links to uploaded files on wiki pages
parent
0f449ecc
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
0 deletions
+17
-0
changelogs/unreleased/42031-fix-links-to-uploads-in-wikis.yml
...gelogs/unreleased/42031-fix-links-to-uploads-in-wikis.yml
+5
-0
lib/banzai/filter/wiki_link_filter/rewriter.rb
lib/banzai/filter/wiki_link_filter/rewriter.rb
+4
-0
spec/lib/banzai/filter/wiki_link_filter_spec.rb
spec/lib/banzai/filter/wiki_link_filter_spec.rb
+8
-0
No files found.
changelogs/unreleased/42031-fix-links-to-uploads-in-wikis.yml
0 → 100644
View file @
31e59219
---
title
:
Fix links to uploaded files on wiki pages
merge_request
:
16499
author
:
type
:
fixed
This diff is collapsed.
Click to expand it.
lib/banzai/filter/wiki_link_filter/rewriter.rb
View file @
31e59219
...
...
@@ -9,6 +9,10 @@ module Banzai
end
def
apply_rules
# Special case: relative URLs beginning with `/uploads/` refer to
# user-uploaded files and will be handled elsewhere.
return
@uri
.
to_s
if
@uri
.
relative?
&&
@uri
.
path
.
starts_with?
(
'/uploads/'
)
apply_file_link_rules!
apply_hierarchical_link_rules!
apply_relative_link_rules!
...
...
This diff is collapsed.
Click to expand it.
spec/lib/banzai/filter/wiki_link_filter_spec.rb
View file @
31e59219
...
...
@@ -10,15 +10,23 @@ describe Banzai::Filter::WikiLinkFilter do
it
"doesn't rewrite absolute links"
do
filtered_link
=
filter
(
"<a href='http://example.com:8000/'>Link</a>"
,
project_wiki:
wiki
).
children
[
0
]
expect
(
filtered_link
.
attribute
(
'href'
).
value
).
to
eq
(
'http://example.com:8000/'
)
end
it
"doesn't rewrite links to project uploads"
do
filtered_link
=
filter
(
"<a href='/uploads/a.test'>Link</a>"
,
project_wiki:
wiki
).
children
[
0
]
expect
(
filtered_link
.
attribute
(
'href'
).
value
).
to
eq
(
'/uploads/a.test'
)
end
describe
"invalid links"
do
invalid_links
=
[
"http://:8080"
,
"http://"
,
"http://:8080/path"
]
invalid_links
.
each
do
|
invalid_link
|
it
"doesn't rewrite invalid invalid_links like
#{
invalid_link
}
"
do
filtered_link
=
filter
(
"<a href='
#{
invalid_link
}
'>Link</a>"
,
project_wiki:
wiki
).
children
[
0
]
expect
(
filtered_link
.
attribute
(
'href'
).
value
).
to
eq
(
invalid_link
)
end
end
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment