Reputation: 2070
Is there anyway to link to an external file (non http url) in GitLab Flavored Markdown?
<a href="file:///my/file/path">link text</a>
[[file:///my/file/path link text]]
Upvotes: 2
Views: 3626
Reputation: 4096
The file://
protocol is not included in the sanitation filter whitelist referenced by gitlab in the documentation.
You could manually edit embedded/service/gitlab-rails/lib/gitlab/markdown.rb
in your gitlab installation, add the protocol to the whitelist yourself and restart gitlab after that to apply the changes (just insert the line with the leading +
):
whitelist = HTML::Pipeline::SanitizationFilter::WHITELIST
whitelist[:attributes][:all].push('class', 'id')
whitelist[:elements].push('span')
+ whitelist[:protocols]['a']['href'] = ['file'].concat(whitelist[:protocols]['a']['href'])
# Remove the rel attribute that the sanitize gem adds, and remove the
# href attribute if it contains inline javascript
but this is probably not the best idea, because it will cause occasional headaches when upgrading the gitlab installation.
And the desired file://
links will still not open as expected without additional configuration steps or addon installations on the client side (see here).
Upvotes: 2
Reputation: 3576
The normal markdown hyperlink syntax should work: [file description](file:///test/location/file)
Upvotes: 0