summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2008-03-09 11:47:36 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2008-03-09 11:47:36 +0000
commita92cce385105d0f40d9bd80c73578ade42958ee3 (patch)
tree633c4eac7f18832c037cb9a0191bdcf1b377850c /lib
parent522b9e6b5b1bf4f38d33b153eaa72249f2c0e507 (diff)
downloadredmine-a92cce385105d0f40d9bd80c73578ade42958ee3.tar.gz
redmine-a92cce385105d0f40d9bd80c73578ade42958ee3.zip
Textile formatting:
* escape html tags, except pre tags (#807, #795) * try to avoid unwanted quick phrase modifiers git-svn-id: http://redmine.rubyforge.org/svn/trunk@1216 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'lib')
-rw-r--r--lib/redcloth.rb15
1 files changed, 11 insertions, 4 deletions
diff --git a/lib/redcloth.rb b/lib/redcloth.rb
index b614614c4..7e88007a6 100644
--- a/lib/redcloth.rb
+++ b/lib/redcloth.rb
@@ -295,6 +295,7 @@ class RedCloth < String
@pre_list = []
rip_offtags text
no_textile text
+ escape_html_tags text
hard_break text
unless @lite_mode
refs text
@@ -375,18 +376,18 @@ class RedCloth < String
re =
case rtype
when :limit
- /(\W)
+ /(^|[>\s])
(#{rcq})
(#{C})
(?::(\S+?))?
- (\S.*?\S|\S)
+ ([^\s\-].*?[^\s\-]|\w)
#{rcq}
- (?=\W)/x
+ (?=[[:punct:]]|\s|$)/x
else
/(#{rcq})
(#{C})
(?::(\S+))?
- (\S.*?\S|\S)
+ ([^\s\-].*?[^\s\-]|\w)
#{rcq}/xm
end
[rc, ht, re, rtype]
@@ -1128,5 +1129,11 @@ class RedCloth < String
end
end
end
+
+ ALLOWED_TAGS = %w(redpre pre)
+
+ def escape_html_tags(text)
+ text.gsub!(%r{<((\/?)(\w+))}) {|m| ALLOWED_TAGS.include?($3) ? "<#{$1}" : "&lt;#{$1}" }
+ end
end