Patch #42737 » 0001-Replacing-html-pipeline-with-Loofah-for-HTML-Filteri.patch
| Gemfile | ||
|---|---|---|
| 37 | 37 |
gem 'rotp', '>= 5.0.0' |
| 38 | 38 |
gem 'rqrcode' |
| 39 | 39 | |
| 40 |
# HTML pipeline and sanitization |
|
| 41 |
gem "html-pipeline", "~> 2.13.2" |
|
| 42 |
gem "sanitize", "~> 6.0" |
|
| 40 |
# HTML sanitization |
|
| 41 |
gem "sanitize", "~> 7.0" |
|
| 43 | 42 | |
| 44 | 43 |
# Triggering of Webhooks |
| 45 | 44 |
gem "rest-client", "~> 2.1" |
| lib/redmine/wiki_formatting/common_mark/alerts_icons_filter.rb | ||
|---|---|---|
| 30 | 30 |
'important' => 'message-report', |
| 31 | 31 |
}.freeze |
| 32 | 32 | |
| 33 |
class AlertsIconsFilter < HTML::Pipeline::Filter
|
|
| 34 |
def call
|
|
| 33 |
class AlertsIconsFilter < Loofah::Scrubber
|
|
| 34 |
def scrub(doc)
|
|
| 35 | 35 |
doc.search("p.markdown-alert-title").each do |node|
|
| 36 | 36 |
parent_node = node.parent |
| 37 | 37 |
parent_class_attr = parent_node['class'] # e.g., "markdown-alert markdown-alert-note" |
| lib/redmine/wiki_formatting/common_mark/external_links_filter.rb | ||
|---|---|---|
| 24 | 24 |
module CommonMark |
| 25 | 25 |
# adds class="external" to external links, and class="email" to mailto |
| 26 | 26 |
# links |
| 27 |
class ExternalLinksFilter < HTML::Pipeline::Filter
|
|
| 28 |
def call
|
|
| 29 |
doc.search("a").each do |node|
|
|
| 27 |
class ExternalLinksFilter < Loofah::Scrubber
|
|
| 28 |
def scrub(node)
|
|
| 29 |
if node.name == 'a'
|
|
| 30 | 30 |
url = node["href"] |
| 31 |
next unless url
|
|
| 32 |
next if url.starts_with?("/") || url.starts_with?("#") || !url.include?(':')
|
|
| 31 |
return unless url
|
|
| 32 |
return if url.starts_with?("/") || url.starts_with?("#") || !url.include?(':')
|
|
| 33 | 33 | |
| 34 | 34 |
scheme = begin |
| 35 | 35 |
URI.parse(url).scheme |
| 36 | 36 |
rescue |
| 37 | 37 |
nil |
| 38 | 38 |
end |
| 39 |
next if scheme.blank?
|
|
| 39 |
return if scheme.blank?
|
|
| 40 | 40 | |