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
c92372e8
Commit
c92372e8
authored
Sep 29, 2018
by
Stan Hu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Prevent Error 500s with invalid relative links
https://gitlab.com/gitlab-org/gitlab-ce/issues/52009
parent
d9241761
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
1 deletion
+15
-1
changelogs/unreleased/sh-fix-issue-52009.yml
changelogs/unreleased/sh-fix-issue-52009.yml
+5
-0
lib/banzai/filter/relative_link_filter.rb
lib/banzai/filter/relative_link_filter.rb
+5
-1
spec/lib/banzai/filter/relative_link_filter_spec.rb
spec/lib/banzai/filter/relative_link_filter_spec.rb
+5
-0
No files found.
changelogs/unreleased/sh-fix-issue-52009.yml
0 → 100644
View file @
c92372e8
---
title
:
Prevent Error 500s with invalid relative links
merge_request
:
22001
author
:
type
:
fixed
lib/banzai/filter/relative_link_filter.rb
View file @
c92372e8
...
...
@@ -60,7 +60,11 @@ module Banzai
path_parts
.
unshift
(
relative_url_root
,
project
.
full_path
)
end
begin
path
=
Addressable
::
URI
.
escape
(
File
.
join
(
*
path_parts
))
rescue
Addressable
::
URI
::
InvalidURIError
return
end
html_attr
.
value
=
if
context
[
:only_path
]
...
...
spec/lib/banzai/filter/relative_link_filter_spec.rb
View file @
c92372e8
...
...
@@ -83,6 +83,11 @@ describe Banzai::Filter::RelativeLinkFilter do
expect
{
filter
(
act
)
}.
not_to
raise_error
end
it
'does not raise an exception with a space in the path'
do
act
=
link
(
"/uploads/d18213acd3732630991986120e167e3d/Landscape_8.jpg
\n
But here's some more unexpected text :smile:)"
)
expect
{
filter
(
act
)
}.
not_to
raise_error
end
it
'ignores ref if commit is passed'
do
doc
=
filter
(
link
(
'non/existent.file'
),
commit:
project
.
commit
(
'empty-branch'
)
)
expect
(
doc
.
at_css
(
'a'
)[
'href'
])
...
...
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