Feature #32938 » 0002-Split-multiple-classes-and-modules-that-existed-in-t.patch
| app/models/anonymous_user.rb | ||
|---|---|---|
| 1 |
# frozen_string_literal: true |
|
| 2 | ||
| 3 |
# Redmine - project management software |
|
| 4 |
# Copyright (C) 2006-2021 Jean-Philippe Lang |
|
| 5 |
# |
|
| 6 |
# This program is free software; you can redistribute it and/or |
|
| 7 |
# modify it under the terms of the GNU General Public License |
|
| 8 |
# as published by the Free Software Foundation; either version 2 |
|
| 9 |
# of the License, or (at your option) any later version. |
|
| 10 |
# |
|
| 11 |
# This program is distributed in the hope that it will be useful, |
|
| 12 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
| 13 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
| 14 |
# GNU General Public License for more details. |
|
| 15 |
# |
|
| 16 |
# You should have received a copy of the GNU General Public License |
|
| 17 |
# along with this program; if not, write to the Free Software |
|
| 18 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
| 19 | ||
| 20 |
class AnonymousUser < User |
|
| 21 |
validate :validate_anonymous_uniqueness, :on => :create |
|
| 22 | ||
| 23 |
self.valid_statuses = [STATUS_ANONYMOUS] |
|
| 24 | ||
| 25 |
def validate_anonymous_uniqueness |
|
| 26 |
# There should be only one AnonymousUser in the database |
|
| 27 |
errors.add :base, 'An anonymous user already exists.' if AnonymousUser.unscoped.exists? |
|
| 28 |
end |
|
| 29 | ||
| 30 |
def available_custom_fields |
|
| 31 |
[] |
|
| 32 |
end |
|
| 33 | ||
| 34 |
# Overrides a few properties |
|
| 35 |
def logged?; false end |
|
| 36 |
def admin; false end |
|
| 37 |
def name(*args); I18n.t(:label_user_anonymous) end |
|
| 38 |
def mail=(*args); nil end |
|
| 39 |
def mail; nil end |
|
| 40 |
def time_zone; nil end |
|
| 41 |
def rss_key; nil end |
|
| 42 | ||
| 43 |
def pref |
|
| 44 |
UserPreference.new(:user => self) |
|
| 45 |
end |
|
| 46 | ||
| 47 |
# Returns the user's bult-in role |
|
| 48 |
def builtin_role |
|
| 49 |
@builtin_role ||= Role.anonymous |
|
| 50 |
end |
|
| 51 | ||
| 52 |
def membership(*args) |
|
| 53 |
nil |
|
| 54 |
end |
|
| 55 | ||
| 56 |
def member_of?(*args) |
|
| 57 |
false |
|
| 58 |
end |
|
| 59 | ||
| 60 |
# Anonymous user can not be destroyed |
|
| 61 |
def destroy |
|
| 62 |
false |
|
| 63 |
end |
|
| 64 | ||
| 65 |
protected |
|
| 66 | ||
| 67 |
def instantiate_email_address |
|
| 68 |
end |
|
| 69 |
end |
|
| app/models/user.rb | ||
|---|---|---|
| 999 | 999 |
end |
| 1000 | 1000 |
end |
| 1001 | 1001 |
end |
| 1002 | ||
| 1003 |
class AnonymousUser < User |
|
| 1004 |
validate :validate_anonymous_uniqueness, :on => :create |
|
| 1005 | ||
| 1006 |
self.valid_statuses = [STATUS_ANONYMOUS] |
|
| 1007 | ||
| 1008 |
def validate_anonymous_uniqueness |
|
| 1009 |
# There should be only one AnonymousUser in the database |
|
| 1010 |
errors.add :base, 'An anonymous user already exists.' if AnonymousUser.unscoped.exists? |
|
| 1011 |
end |
|
| 1012 | ||
| 1013 |
def available_custom_fields |
|
| 1014 |
[] |
|
| 1015 |
end |
|
| 1016 | ||
| 1017 |
# Overrides a few properties |
|
| 1018 |
def logged?; false end |
|
| 1019 |
def admin; false end |
|
| 1020 |
def name(*args); I18n.t(:label_user_anonymous) end |
|
| 1021 |
def mail=(*args); nil end |
|
| 1022 |
def mail; nil end |
|
| 1023 |
def time_zone; nil end |
|
| 1024 |
def rss_key; nil end |
|
| 1025 | ||
| 1026 |
def pref |
|
| 1027 |
UserPreference.new(:user => self) |
|
| 1028 |
end |
|
| 1029 | ||
| 1030 |
# Returns the user's bult-in role |
|
| 1031 |
def builtin_role |
|
| 1032 |
@builtin_role ||= Role.anonymous |
|
| 1033 |
end |
|
| 1034 | ||
| 1035 |
def membership(*args) |
|
| 1036 |
nil |
|
| 1037 |
end |
|
| 1038 | ||
| 1039 |
def member_of?(*args) |
|
| 1040 |
false |
|
| 1041 |
end |
|
| 1042 | ||
| 1043 |
# Anonymous user can not be destroyed |
|
| 1044 |
def destroy |
|
| 1045 |
false |
|
| 1046 |
end |
|
| 1047 | ||
| 1048 |
protected |
|
| 1049 | ||
| 1050 |
def instantiate_email_address |
|
| 1051 |
end |
|
| 1052 |
end |
|
| app/models/wiki_annotate.rb | ||
|---|---|---|
| 1 |
# frozen_string_literal: true |
|
| 2 | ||
| 3 |
# Redmine - project management software |
|
| 4 |
# Copyright (C) 2006-2021 Jean-Philippe Lang |
|
| 5 |
# |
|
| 6 |
# This program is free software; you can redistribute it and/or |
|
| 7 |
# modify it under the terms of the GNU General Public License |
|
| 8 |
# as published by the Free Software Foundation; either version 2 |
|
| 9 |
# of the License, or (at your option) any later version. |
|
| 10 |
# |
|
| 11 |
# This program is distributed in the hope that it will be useful, |
|
| 12 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
| 13 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
| 14 |
# GNU General Public License for more details. |
|
| 15 |
# |
|
| 16 |
# You should have received a copy of the GNU General Public License |
|
| 17 |
# along with this program; if not, write to the Free Software |
|
| 18 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
| 19 | ||
| 20 |
class WikiAnnotate |
|
| 21 |
attr_reader :lines, :content |
|
| 22 | ||
| 23 |
def initialize(content) |
|
| 24 |
@content = content |
|
| 25 |
current = content |
|
| 26 |
current_lines = current.text.split(/\r?\n/) |
|
| 27 |
@lines = current_lines.collect {|t| [nil, nil, t]}
|
|
| 28 |
positions = [] |
|
| 29 |
current_lines.size.times {|i| positions << i}
|
|
| 30 |
while current.previous |
|
| 31 |
d = current.previous.text.split(/\r?\n/).diff(current.text.split(/\r?\n/)).diffs.flatten |
|
| 32 |
d.each_slice(3) do |s| |
|
| 33 |
sign, line = s[0], s[1] |
|
| 34 |
if sign == '+' && positions[line] && positions[line] != -1 |
|
| 35 |
if @lines[positions[line]][0].nil? |
|
| 36 |
@lines[positions[line]][0] = current.version |
|
| 37 |
@lines[positions[line]][1] = current.author |
|
| 38 |
end |
|
| 39 |
end |
|
| 40 |
end |
|
| 41 |
d.each_slice(3) do |s| |
|
| 42 |
sign, line = s[0], s[1] |
|
| 43 |
if sign == '-' |
|
| 44 |
positions.insert(line, -1) |
|
| 45 |
else |
|
| 46 |
positions[line] = nil |
|
| 47 |
end |
|
| 48 |
end |
|
| 49 |
positions.compact! |
|
| 50 |
# Stop if every line is annotated |
|
| 51 |
break unless @lines.detect {|line| line[0].nil?}
|
|
| 52 | ||
| 53 |
current = current.previous |
|
| 54 |
end |
|
| 55 |
@lines.each do |line| |
|
| 56 |
line[0] ||= current.version |
|
| 57 |
# if the last known version is > 1 (eg. history was cleared), we don't know the author |
|
| 58 |
line[1] ||= current.author if current.version == 1 |
|
| 59 |
end |
|
| 60 |
end |
|
| 61 |
end |
|
| app/models/wiki_diff.rb | ||
|---|---|---|
| 1 |
# frozen_string_literal: true |
|
| 2 | ||
| 3 |
# Redmine - project management software |
|
| 4 |
# Copyright (C) 2006-2021 Jean-Philippe Lang |
|
| 5 |
# |
|
| 6 |
# This program is free software; you can redistribute it and/or |
|
| 7 |
# modify it under the terms of the GNU General Public License |
|
| 8 |
# as published by the Free Software Foundation; either version 2 |
|
| 9 |
# of the License, or (at your option) any later version. |
|
| 10 |
# |
|
| 11 |
# This program is distributed in the hope that it will be useful, |
|
| 12 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
| 13 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
| 14 |
# GNU General Public License for more details. |
|
| 15 |
# |
|
| 16 |
# You should have received a copy of the GNU General Public License |
|
| 17 |
# along with this program; if not, write to the Free Software |
|
| 18 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
| 19 | ||
| 20 |
class WikiDiff < Redmine::Helpers::Diff |
|
| 21 |
attr_reader :content_to, :content_from |
|
| 22 | ||
| 23 |
def initialize(content_to, content_from) |
|
| 24 |
@content_to = content_to |
|
| 25 |
@content_from = content_from |
|
| 26 |
super(content_to.text, content_from.text) |
|
| 27 |
end |
|
| 28 |
end |
|
| app/models/wiki_page.rb | ||
|---|---|---|
| 290 | 290 |
(association(:content).loaded? ? content : content_without_text).try(name) |
| 291 | 291 |
end |
| 292 | 292 |
end |
| 293 | ||
| 294 |
class WikiDiff < Redmine::Helpers::Diff |
|
| 295 |
attr_reader :content_to, :content_from |
|
| 296 | ||
| 297 |
def initialize(content_to, content_from) |
|
| 298 |
@content_to = content_to |
|
| 299 |
@content_from = content_from |
|
| 300 |
super(content_to.text, content_from.text) |
|
| 301 |
end |
|
| 302 |
end |
|
| 303 | ||
| 304 |
class WikiAnnotate |
|
| 305 |
attr_reader :lines, :content |
|
| 306 | ||
| 307 |
def initialize(content) |
|
| 308 |
@content = content |
|
| 309 |
current = content |
|
| 310 |
current_lines = current.text.split(/\r?\n/) |
|
| 311 |
@lines = current_lines.collect {|t| [nil, nil, t]}
|
|
| 312 |
positions = [] |
|
| 313 |
current_lines.size.times {|i| positions << i}
|
|
| 314 |
while current.previous |
|
| 315 |
d = current.previous.text.split(/\r?\n/).diff(current.text.split(/\r?\n/)).diffs.flatten |
|
| 316 |
d.each_slice(3) do |s| |
|
| 317 |
sign, line = s[0], s[1] |
|
| 318 |
if sign == '+' && positions[line] && positions[line] != -1 |
|
| 319 |
if @lines[positions[line]][0].nil? |
|
| 320 |
@lines[positions[line]][0] = current.version |
|
| 321 |
@lines[positions[line]][1] = current.author |
|
| 322 |
end |
|
| 323 |
end |
|
| 324 |
end |
|
| 325 |
d.each_slice(3) do |s| |
|
| 326 |
sign, line = s[0], s[1] |
|
| 327 |
if sign == '-' |
|
| 328 |
positions.insert(line, -1) |
|
| 329 |
else |
|
| 330 |
positions[line] = nil |
|
| 331 |
end |
|
| 332 |
end |
|
| 333 |
positions.compact! |
|
| 334 |
# Stop if every line is annotated |
|
| 335 |
break unless @lines.detect {|line| line[0].nil?}
|
|
| 336 | ||
| 337 |
current = current.previous |
|
| 338 |
end |
|
| 339 |
@lines.each do |line| |
|
| 340 |
line[0] ||= current.version |
|
| 341 |
# if the last known version is > 1 (eg. history was cleared), we don't know the author |
|
| 342 |
line[1] ||= current.author if current.version == 1 |
|
| 343 |
end |
|
| 344 |
end |
|
| 345 |
end |
|
| lib/redmine.rb | ||
|---|---|---|
| 44 | 44 |
require 'issue_relation' |
| 45 | 45 |
require 'redmine/configuration' |
| 46 | 46 |
require 'redmine/scm/adapters/command_failed' |
| 47 |
require 'redmine/wiki_formatting/links_helper' |
|
| 47 | 48 |
require 'redmine/wiki_formatting' |
| 48 | 49 |
require 'redmine/wiki_formatting/macros' |
| 49 | 50 |
require 'redmine/wiki_formatting/html_parser' |
| lib/redmine/wiki_formatting.rb | ||
|---|---|---|
| 115 | 115 |
end |
| 116 | 116 |
end |
| 117 | 117 | |
| 118 |
module LinksHelper |
|
| 119 |
AUTO_LINK_RE = %r{
|
|
| 120 |
( # leading text |
|
| 121 |
<\w+[^>]*?>| # leading HTML tag, or |
|
| 122 |
[\s\(\[,;]| # leading punctuation, or |
|
| 123 |
^ # beginning of line |
|
| 124 |
) |
|
| 125 |
( |
|
| 126 |
(?:https?://)| # protocol spec, or |
|
| 127 |
(?:s?ftps?://)| |
|
| 128 |
(?:www\.) # www.* |
|
| 129 |
) |
|
| 130 |
( |
|
| 131 |
([^<]\S*?) # url |
|
| 132 |
(\/)? # slash |
|
| 133 |
) |
|
| 134 |
((?:>)?|[^[:alnum:]_\=\/;\(\)\-]*?) # post |
|
| 135 |
(?=<|\s|$) |
|
| 136 |
}x unless const_defined?(:AUTO_LINK_RE) |
|
| 137 | ||
| 138 |
# Destructively replaces urls into clickable links |
|
| 139 |
def auto_link!(text) |
|
| 140 |
text.gsub!(AUTO_LINK_RE) do |
|
| 141 |
all, leading, proto, url, post = $&, $1, $2, $3, $6 |
|
| 142 |
if /<a\s/i.match?(leading) || /![<>=]?/.match?(leading) |
|
| 143 |
# don't replace URLs that are already linked |
|
| 144 |
# and URLs prefixed with ! !> !< != (textile images) |
|
| 145 |
all |
|
| 146 |
else |
|
| 147 |
# Idea below : an URL with unbalanced parenthesis and |
|
| 148 |
# ending by ')' is put into external parenthesis |
|
| 149 |
if url[-1] == ")" and ((url.count("(") - url.count(")")) < 0)
|
|
| 150 |
url = url[0..-2] # discard closing parenthesis from url |
|
| 151 |
post = ")" + post # add closing parenthesis to post |
|
| 152 |
end |
|
| 153 |
content = proto + url |
|
| 154 |
href = "#{proto=="www."?"http://www.":proto}#{url}"
|
|
| 155 |
%(#{leading}<a class="external" href="#{ERB::Util.html_escape href}">#{ERB::Util.html_escape content}</a>#{post}).html_safe
|
|
| 156 |
end |
|
| 157 |
end |
|
| 158 |
end |
|
| 159 | ||
| 160 |
# Destructively replaces email addresses into clickable links |
|
| 161 |
def auto_mailto!(text) |
|
| 162 |
text.gsub!(/([\w\.!#\$%\-+.\/]+@[A-Za-z0-9\-]+(\.[A-Za-z0-9\-]+)+)/) do |
|
| 163 |
mail = $1 |
|
| 164 |
if /<a\b[^>]*>(.*)(#{Regexp.escape(mail)})(.*)<\/a>/.match?(text)
|
|
| 165 |
|
|
| 166 |
else |
|
| 167 |
%(<a class="email" href="mailto:#{ERB::Util.html_escape mail}">#{ERB::Util.html_escape mail}</a>).html_safe
|
|
| 168 |
end |
|
| 169 |
end |
|
| 170 |
end |
|
| 171 | ||
| 172 |
def restore_redmine_links(html) |
|
| 173 |
# restore wiki links eg. [[Foo]] |
|
| 174 |
html.gsub!(%r{\[<a href="(.*?)">(.*?)</a>\]}) do
|
|
| 175 |
"[[#{$2}]]"
|
|
| 176 |
end |
|
| 177 |
# restore Redmine links with double-quotes, eg. version:"1.0" |
|
| 178 |
html.gsub!(/(\w):"(.+?)"/) do |
|
| 179 |
"#{$1}:\"#{$2}\""
|
|
| 180 |
end |
|
| 181 |
# restore user links with @ in login name eg. [@jsmith@somenet.foo] |
|
| 182 |
html.gsub!(%r{[@\A]<a(\sclass="email")? href="mailto:(.*?)">(.*?)</a>}) do
|
|
| 183 |
"@#{$2}"
|
|
| 184 |
end |
|
| 185 |
# restore user links with @ in login name eg. [user:jsmith@somenet.foo] |
|
| 186 |
html.gsub!(%r{\buser:<a(\sclass="email")? href="mailto:(.*?)">(.*?)<\/a>}) do
|
|
| 187 |
"user:#{$2}"
|
|
| 188 |
end |
|
| 189 |
# restore attachments links with @ in file name eg. [attachment:image@2x.png] |
|
| 190 |
html.gsub!(%r{\battachment:<a(\sclass="email")? href="mailto:(.*?)">(.*?)</a>}) do
|
|
| 191 |
"attachment:#{$2}"
|
|
| 192 |
end |
|
| 193 |
# restore hires images which are misrecognized as email address eg. [printscreen@2x.png] |
|
| 194 |
html.gsub!(%r{<a(\sclass="email")? href="mailto:[^"]+@\dx\.(bmp|gif|jpg|jpe|jpeg|png)">(.*?)</a>}) do
|
|
| 195 |
"#{$3}"
|
|
| 196 |
end |
|
| 197 |
html |
|
| 198 |
end |
|
| 199 |
end |
|
| 200 | ||
| 201 | 118 |
# Default formatter module |
| 202 | 119 |
module NullFormatter |
| 203 | 120 |
class Formatter |
| lib/redmine/wiki_formatting/links_helper.rb | ||
|---|---|---|
| 1 |
# frozen_string_literal: true |
|
| 2 | ||
| 3 |
# Redmine - project management software |
|
| 4 |
# Copyright (C) 2006-2021 Jean-Philippe Lang |
|
| 5 |
# |
|
| 6 |
# This program is free software; you can redistribute it and/or |
|
| 7 |
# modify it under the terms of the GNU General Public License |
|
| 8 |
# as published by the Free Software Foundation; either version 2 |
|
| 9 |
# of the License, or (at your option) any later version. |
|
| 10 |
# |
|
| 11 |
# This program is distributed in the hope that it will be useful, |
|
| 12 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
| 13 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
| 14 |
# GNU General Public License for more details. |
|
| 15 |
# |
|
| 16 |
# You should have received a copy of the GNU General Public License |
|
| 17 |
# along with this program; if not, write to the Free Software |
|
| 18 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
| 19 | ||
| 20 |
require 'loofah/helpers' |
|
| 21 | ||
| 22 |
module Redmine |
|
| 23 |
module WikiFormatting |
|
| 24 |
module LinksHelper |
|
| 25 |
AUTO_LINK_RE = %r{
|
|
| 26 |
( # leading text |
|
| 27 |
<\w+[^>]*?>| # leading HTML tag, or |
|
| 28 |
[\s\(\[,;]| # leading punctuation, or |
|
| 29 |
^ # beginning of line |
|
| 30 |
) |
|
| 31 |
( |
|
| 32 |
(?:https?://)| # protocol spec, or |
|
| 33 |
(?:s?ftps?://)| |
|
| 34 |
(?:www\.) # www.* |
|
| 35 |
) |
|
| 36 |
( |
|
| 37 |
([^<]\S*?) # url |
|
| 38 |
(\/)? # slash |
|
| 39 |
) |
|
| 40 |
((?:>)?|[^[:alnum:]_\=\/;\(\)\-]*?) # post |
|
| 41 |
(?=<|\s|$) |
|
| 42 |
}x unless const_defined?(:AUTO_LINK_RE) |
|
| 43 | ||
| 44 |
# Destructively replaces urls into clickable links |
|
| 45 |
def auto_link!(text) |
|
| 46 |
text.gsub!(AUTO_LINK_RE) do |
|
| 47 |
all, leading, proto, url, post = $&, $1, $2, $3, $6 |
|
| 48 |
if /<a\s/i.match?(leading) || /![<>=]?/.match?(leading) |
|
| 49 |
# don't replace URLs that are already linked |
|
| 50 |
# and URLs prefixed with ! !> !< != (textile images) |
|
| 51 |
all |
|
| 52 |
else |
|
| 53 |
# Idea below : an URL with unbalanced parenthesis and |
|
| 54 |
# ending by ')' is put into external parenthesis |
|
| 55 |
if url[-1] == ")" and ((url.count("(") - url.count(")")) < 0)
|
|
| 56 |
url = url[0..-2] # discard closing parenthesis from url |
|
| 57 |
post = ")" + post # add closing parenthesis to post |
|
| 58 |
end |
|
| 59 |
content = proto + url |
|
| 60 |
href = "#{proto=="www."?"http://www.":proto}#{url}"
|
|
| 61 |
%(#{leading}<a class="external" href="#{ERB::Util.html_escape href}">#{ERB::Util.html_escape content}</a>#{post}).html_safe
|
|
| 62 |
end |
|
| 63 |
end |
|
| 64 |
end |
|
| 65 | ||
| 66 |
# Destructively replaces email addresses into clickable links |
|
| 67 |
def auto_mailto!(text) |
|
| 68 |
text.gsub!(/([\w\.!#\$%\-+.\/]+@[A-Za-z0-9\-]+(\.[A-Za-z0-9\-]+)+)/) do |
|
| 69 |
mail = $1 |
|
| 70 |
if /<a\b[^>]*>(.*)(#{Regexp.escape(mail)})(.*)<\/a>/.match?(text)
|
|
| 71 |
|
|
| 72 |
else |
|
| 73 |
%(<a class="email" href="mailto:#{ERB::Util.html_escape mail}">#{ERB::Util.html_escape mail}</a>).html_safe
|
|
| 74 |
end |
|
| 75 |
end |
|
| 76 |
end |
|
| 77 | ||
| 78 |
def restore_redmine_links(html) |
|
| 79 |
# restore wiki links eg. [[Foo]] |
|
| 80 |
html.gsub!(%r{\[<a href="(.*?)">(.*?)</a>\]}) do
|
|
| 81 |
"[[#{$2}]]"
|
|
| 82 |
end |
|
| 83 |
# restore Redmine links with double-quotes, eg. version:"1.0" |
|
| 84 |
html.gsub!(/(\w):"(.+?)"/) do |
|
| 85 |
"#{$1}:\"#{$2}\""
|
|
| 86 |
end |
|
| 87 |
# restore user links with @ in login name eg. [@jsmith@somenet.foo] |
|
| 88 |
html.gsub!(%r{[@\A]<a(\sclass="email")? href="mailto:(.*?)">(.*?)</a>}) do
|
|
| 89 |
"@#{$2}"
|
|
| 90 |
end |
|
| 91 |
# restore user links with @ in login name eg. [user:jsmith@somenet.foo] |
|
| 92 |
html.gsub!(%r{\buser:<a(\sclass="email")? href="mailto:(.*?)">(.*?)<\/a>}) do
|
|
| 93 |
"user:#{$2}"
|
|
| 94 |
end |
|
| 95 |
# restore attachments links with @ in file name eg. [attachment:image@2x.png] |
|
| 96 |
html.gsub!(%r{\battachment:<a(\sclass="email")? href="mailto:(.*?)">(.*?)</a>}) do
|
|
| 97 |
"attachment:#{$2}"
|
|
| 98 |
end |
|
| 99 |
# restore hires images which are misrecognized as email address eg. [printscreen@2x.png] |
|
| 100 |
html.gsub!(%r{<a(\sclass="email")? href="mailto:[^"]+@\dx\.(bmp|gif|jpg|jpe|jpeg|png)">(.*?)</a>}) do
|
|
| 101 |
"#{$3}"
|
|
| 102 |
end |
|
| 103 |
html |
|
| 104 |
end |
|
| 105 |
end |
|
| 106 |
end |
|
| 107 |
end |
|