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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
7e25ff30
Commit
7e25ff30
authored
Feb 04, 2019
by
Brett Walker
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Catch possible Addressable::URI::InvalidURIError
parent
280b6f6f
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
1 deletion
+17
-1
changelogs/unreleased/57227-absolute-uri-missing-hierarchical-segment.yml
...eased/57227-absolute-uri-missing-hierarchical-segment.yml
+5
-0
lib/banzai/filter/autolink_filter.rb
lib/banzai/filter/autolink_filter.rb
+5
-1
spec/lib/banzai/filter/autolink_filter_spec.rb
spec/lib/banzai/filter/autolink_filter_spec.rb
+7
-0
No files found.
changelogs/unreleased/57227-absolute-uri-missing-hierarchical-segment.yml
0 → 100644
View file @
7e25ff30
---
title
:
Fix potential Addressable::URI::InvalidURIError
merge_request
:
24908
author
:
type
:
fixed
lib/banzai/filter/autolink_filter.rb
View file @
7e25ff30
...
@@ -114,7 +114,11 @@ module Banzai
...
@@ -114,7 +114,11 @@ module Banzai
# Since this came from a Text node, make sure the new href is encoded.
# Since this came from a Text node, make sure the new href is encoded.
# `commonmarker` percent encodes the domains of links it handles, so
# `commonmarker` percent encodes the domains of links it handles, so
# do the same (instead of using `normalized_encode`).
# do the same (instead of using `normalized_encode`).
begin
href_safe
=
Addressable
::
URI
.
encode
(
match
).
html_safe
href_safe
=
Addressable
::
URI
.
encode
(
match
).
html_safe
rescue
Addressable
::
URI
::
InvalidURIError
return
uri
.
to_s
end
html_safe_match
=
match
.
html_safe
html_safe_match
=
match
.
html_safe
options
=
link_options
.
merge
(
href:
href_safe
)
options
=
link_options
.
merge
(
href:
href_safe
)
...
...
spec/lib/banzai/filter/autolink_filter_spec.rb
View file @
7e25ff30
...
@@ -121,6 +121,13 @@ describe Banzai::Filter::AutolinkFilter do
...
@@ -121,6 +121,13 @@ describe Banzai::Filter::AutolinkFilter do
expect
(
doc
.
to_s
).
to
eq
(
"See
#{
link
}
"
)
expect
(
doc
.
to_s
).
to
eq
(
"See
#{
link
}
"
)
end
end
it
'does not autolink bad URLs after we remove trailing punctuation'
do
link
=
'http://]'
doc
=
filter
(
"See
#{
link
}
"
)
expect
(
doc
.
to_s
).
to
eq
(
"See
#{
link
}
"
)
end
it
'does not include trailing punctuation'
do
it
'does not include trailing punctuation'
do
[
'.'
,
', ok?'
,
'...'
,
'?'
,
'!'
,
': is that ok?'
].
each
do
|
trailing_punctuation
|
[
'.'
,
', ok?'
,
'...'
,
'?'
,
'!'
,
': is that ok?'
].
each
do
|
trailing_punctuation
|
doc
=
filter
(
"See
#{
link
}#{
trailing_punctuation
}
"
)
doc
=
filter
(
"See
#{
link
}#{
trailing_punctuation
}
"
)
...
...
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