Skip to content
代码片段 群组 项目
提交 8d570b29 编辑于 作者: Brett Walker's avatar Brett Walker
浏览文件

Ignore wiki links that have missing href

An invalid href was being sanitzed/removed,
causing code to fail. Ignore any wiki links that
don’t have an href.

Changelog: fixed
上级 3407dc17
无相关合并请求
......@@ -30,7 +30,7 @@ class WikiLinkGollumFilter < HTML::Pipeline::Filter
# Pattern to match allowed image extensions
ALLOWED_IMAGE_EXTENSIONS = /(jpg|png|gif|svg|bmp)\z/i
CSS_WIKILINK_STYLE = 'a[data-wikilink]'
CSS_WIKILINK_STYLE = 'a[href][data-wikilink]'
XPATH_WIKILINK_STYLE = Gitlab::Utils::Nokogiri.css_to_xpath(CSS_WIKILINK_STYLE).freeze
def call
......
......@@ -192,6 +192,14 @@
end
# rubocop:enable Layout/LineLength
context 'when the href gets sanitized out' do
it 'ignores the link' do
doc = pipeline_filter('[[test|http://]]', wiki: wiki)
expect(doc.at_css('a')['data-gollum']).to be_nil
end
end
def pipeline_filter(text, context = {})
context = { project: project, no_sourcepos: true }.merge(context)
......
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册