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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gitlab-ce
Commits
535be93a
Commit
535be93a
authored
May 10, 2016
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Do not process upload links if no project context
parent
c97a81d2
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
5 deletions
+9
-5
lib/banzai/filter/upload_link_filter.rb
lib/banzai/filter/upload_link_filter.rb
+6
-2
spec/lib/banzai/filter/upload_link_filter_spec.rb
spec/lib/banzai/filter/upload_link_filter_spec.rb
+3
-3
No files found.
lib/banzai/filter/upload_link_filter.rb
View file @
535be93a
...
@@ -8,6 +8,8 @@ module Banzai
...
@@ -8,6 +8,8 @@ module Banzai
#
#
class
UploadLinkFilter
<
HTML
::
Pipeline
::
Filter
class
UploadLinkFilter
<
HTML
::
Pipeline
::
Filter
def
call
def
call
return
doc
unless
project
doc
.
search
(
'a'
).
each
do
|
el
|
doc
.
search
(
'a'
).
each
do
|
el
|
process_link_attr
el
.
attribute
(
'href'
)
process_link_attr
el
.
attribute
(
'href'
)
end
end
...
@@ -31,11 +33,13 @@ module Banzai
...
@@ -31,11 +33,13 @@ module Banzai
end
end
def
build_url
(
uri
)
def
build_url
(
uri
)
return
'#'
unless
project
=
context
[
:project
]
File
.
join
(
Gitlab
.
config
.
gitlab
.
url
,
project
.
path_with_namespace
,
uri
)
File
.
join
(
Gitlab
.
config
.
gitlab
.
url
,
project
.
path_with_namespace
,
uri
)
end
end
def
project
context
[
:project
]
end
# Ensure that a :project key exists in context
# Ensure that a :project key exists in context
#
#
# Note that while the key might exist, its value could be nil!
# Note that while the key might exist, its value could be nil!
...
...
spec/lib/banzai/filter/upload_link_filter_spec.rb
View file @
535be93a
...
@@ -79,13 +79,13 @@ describe Banzai::Filter::UploadLinkFilter, lib: true do
...
@@ -79,13 +79,13 @@ describe Banzai::Filter::UploadLinkFilter, lib: true do
let
(
:upload_link
)
{
link
(
'/uploads/e90decf88d8f96fe9e1389afc2e4a91f/test.jpg'
)
}
let
(
:upload_link
)
{
link
(
'/uploads/e90decf88d8f96fe9e1389afc2e4a91f/test.jpg'
)
}
it
'does not raise error'
do
it
'does not raise error'
do
expect
{
raw_filter
(
upload_link
,
project:
nil
)
}.
to_not
raise_error
expect
{
raw_filter
(
upload_link
,
project:
nil
)
}.
not_to
raise_error
end
end
it
'
provides an empty
link'
do
it
'
does not rewrite
link'
do
doc
=
raw_filter
(
upload_link
,
project:
nil
)
doc
=
raw_filter
(
upload_link
,
project:
nil
)
expect
(
doc
.
at_css
(
'a'
)[
'href'
]).
to
eq
'#'
expect
(
doc
.
to_html
).
to
eq
upload_link
end
end
end
end
end
end
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