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
Boxiang Sun
gitlab-ce
Commits
1d478547
Commit
1d478547
authored
Sep 08, 2018
by
Brett Walker
Committed by
Stan Hu
Sep 08, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Resolve "Process urls with spaces in all markdown processing"
parent
6d1b5850
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
24 additions
and
5 deletions
+24
-5
lib/banzai/filter/spaced_link_filter.rb
lib/banzai/filter/spaced_link_filter.rb
+4
-3
lib/banzai/pipeline/gfm_pipeline.rb
lib/banzai/pipeline/gfm_pipeline.rb
+1
-0
lib/banzai/pipeline/wiki_pipeline.rb
lib/banzai/pipeline/wiki_pipeline.rb
+0
-1
spec/helpers/issuables_helper_spec.rb
spec/helpers/issuables_helper_spec.rb
+1
-1
spec/lib/banzai/pipeline/gfm_pipeline_spec.rb
spec/lib/banzai/pipeline/gfm_pipeline_spec.rb
+18
-0
No files found.
lib/banzai/filter/spaced_link_filter.rb
View file @
1d478547
...
@@ -10,11 +10,12 @@ module Banzai
...
@@ -10,11 +10,12 @@ module Banzai
#
#
# CommonMark does not allow spaces in the url portion of a link/url.
# CommonMark does not allow spaces in the url portion of a link/url.
# For example, `[example](page slug)` is not valid.
# For example, `[example](page slug)` is not valid.
# Neither is `![example](test image.jpg)`. However,
# Neither is `![example](test image.jpg)`. However,
particularly
# in our wikis, we support (via RedCarpet) this type of link, allowing
# in our wikis, we support (via RedCarpet) this type of link, allowing
# wiki pages to be easily linked by their title. This filter adds that functionality.
# wiki pages to be easily linked by their title. This filter adds that functionality.
# The intent is for this to only be used in Wikis - in general, we want
#
# to adhere to CommonMark's spec.
# This is a small extension to the CommonMark spec. If they start allowing
# spaces in urls, we could then remove this filter.
#
#
class
SpacedLinkFilter
<
HTML
::
Pipeline
::
Filter
class
SpacedLinkFilter
<
HTML
::
Pipeline
::
Filter
include
ActionView
::
Helpers
::
TagHelper
include
ActionView
::
Helpers
::
TagHelper
...
...
lib/banzai/pipeline/gfm_pipeline.rb
View file @
1d478547
...
@@ -16,6 +16,7 @@ module Banzai
...
@@ -16,6 +16,7 @@ module Banzai
Filter
::
MathFilter
,
Filter
::
MathFilter
,
Filter
::
ColorFilter
,
Filter
::
ColorFilter
,
Filter
::
MermaidFilter
,
Filter
::
MermaidFilter
,
Filter
::
SpacedLinkFilter
,
Filter
::
VideoLinkFilter
,
Filter
::
VideoLinkFilter
,
Filter
::
ImageLazyLoadFilter
,
Filter
::
ImageLazyLoadFilter
,
Filter
::
ImageLinkFilter
,
Filter
::
ImageLinkFilter
,
...
...
lib/banzai/pipeline/wiki_pipeline.rb
View file @
1d478547
...
@@ -5,7 +5,6 @@ module Banzai
...
@@ -5,7 +5,6 @@ module Banzai
@filters
||=
begin
@filters
||=
begin
super
.
insert_after
(
Filter
::
TableOfContentsFilter
,
Filter
::
GollumTagsFilter
)
super
.
insert_after
(
Filter
::
TableOfContentsFilter
,
Filter
::
GollumTagsFilter
)
.
insert_before
(
Filter
::
TaskListFilter
,
Filter
::
WikiLinkFilter
)
.
insert_before
(
Filter
::
TaskListFilter
,
Filter
::
WikiLinkFilter
)
.
insert_before
(
Filter
::
VideoLinkFilter
,
Filter
::
SpacedLinkFilter
)
end
end
end
end
end
end
...
...
spec/helpers/issuables_helper_spec.rb
View file @
1d478547
...
@@ -184,7 +184,7 @@ describe IssuablesHelper do
...
@@ -184,7 +184,7 @@ describe IssuablesHelper do
issuableRef:
"#
#{
issue
.
iid
}
"
,
issuableRef:
"#
#{
issue
.
iid
}
"
,
markdownPreviewPath:
"/
#{
@project
.
full_path
}
/preview_markdown"
,
markdownPreviewPath:
"/
#{
@project
.
full_path
}
/preview_markdown"
,
markdownDocsPath:
'/help/user/markdown'
,
markdownDocsPath:
'/help/user/markdown'
,
markdownVersion:
11
,
markdownVersion:
CacheMarkdownField
::
CACHE_COMMONMARK_VERSION
,
issuableTemplates:
[],
issuableTemplates:
[],
projectPath:
@project
.
path
,
projectPath:
@project
.
path
,
projectNamespace:
@project
.
namespace
.
path
,
projectNamespace:
@project
.
namespace
.
path
,
...
...
spec/lib/banzai/pipeline/gfm_pipeline_spec.rb
View file @
1d478547
...
@@ -87,4 +87,22 @@ describe Banzai::Pipeline::GfmPipeline do
...
@@ -87,4 +87,22 @@ describe Banzai::Pipeline::GfmPipeline do
end
end
end
end
end
end
describe
'markdown link or image urls having spaces'
do
let
(
:project
)
{
create
(
:project
,
:public
)
}
it
'rewrites links with spaces in url'
do
markdown
=
"[Link to Page](page slug)"
output
=
described_class
.
to_html
(
markdown
,
project:
project
)
expect
(
output
).
to
include
(
"href=
\"
page%20slug
\"
"
)
end
it
'rewrites images with spaces in url'
do
markdown
=
"![My Image](test image.png)"
output
=
described_class
.
to_html
(
markdown
,
project:
project
)
expect
(
output
).
to
include
(
"src=
\"
test%20image.png
\"
"
)
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