trac-wiki 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/trac-wiki/parser.rb +6 -6
- data/lib/trac-wiki/version.rb +1 -1
- data/test/parser_test.rb +4 -3
- metadata +1 -1
data/lib/trac-wiki/parser.rb
CHANGED
@@ -209,7 +209,7 @@ module TracWiki
|
|
209
209
|
# markup, for example to add html additional attributes or
|
210
210
|
# to put divs around the imgs.
|
211
211
|
def make_image(uri, attrs='')
|
212
|
-
"<img src=\"#{
|
212
|
+
"<img src=\"#{make_explicit_link(uri)}\"#{make_image_attrs(attrs)}/>"
|
213
213
|
end
|
214
214
|
|
215
215
|
def make_image_attrs(attrs)
|
@@ -219,19 +219,19 @@ module TracWiki
|
|
219
219
|
attrs.strip.split(/\s*,\s*/).each do |opt|
|
220
220
|
case opt
|
221
221
|
when /^\d+[^\d]*$/
|
222
|
-
a['width'] = opt
|
222
|
+
a['width'] = escape_url(opt)
|
223
223
|
when /^(right|left|center)/i
|
224
|
-
a['align'] = opt
|
224
|
+
a['align'] = escape_url(opt)
|
225
225
|
when /^(top|bottom|middle)$/i
|
226
|
-
a['valign'] = opt
|
226
|
+
a['valign'] = escape_url(opt)
|
227
227
|
when /^link=(.*)$/i
|
228
228
|
# pass
|
229
229
|
when /^nolink$/i
|
230
230
|
# pass
|
231
231
|
when /^(align|valign|border|width|height|alt|title|longdesc|class|id|usemap)=(.*)$/i
|
232
|
-
a[$1]=
|
232
|
+
a[$1]= escape_url($2)
|
233
233
|
when /^(margin|margin-(left|right|top|bottom))=(\d+)$/
|
234
|
-
style.push($1 +
|
234
|
+
style.push($1 + ':' + escape_url($3))
|
235
235
|
end
|
236
236
|
end
|
237
237
|
a['style'] = style.join(';') if ! style.empty?
|
data/lib/trac-wiki/version.rb
CHANGED
data/test/parser_test.rb
CHANGED
@@ -449,8 +449,8 @@ describe TracWiki::Parser do
|
|
449
449
|
# Image tags should be escape
|
450
450
|
tc("<p><img src=\"image.jpg\"/></p>\n", "[[Image(image.jpg)]]")
|
451
451
|
tc("<p><img src=\"image.jpg\"/></p>\n", "[[Image(image.jpg)]]", :no_link=>true)
|
452
|
-
tc("<p><img src=\"image.jpg\" alt=\"a
|
453
|
-
tc("<p><img src=\"image.jpg\" alt=\"a
|
452
|
+
tc("<p><img src=\"image.jpg\" alt=\"a%22tag%22\"/></p>\n", "[[Image(image.jpg,alt=a\"tag\")]]")
|
453
|
+
tc("<p><img src=\"image.jpg\" alt=\"a%22tag%22\"/></p>\n", "[[Image(image.jpg,alt=a\"tag\")]]", :no_link=>true)
|
454
454
|
|
455
455
|
# Malicious links should not be converted.
|
456
456
|
tc("<p><a href=\"javascript%3Aalert%28%22Boo%21%22%29\">Click</a></p>\n", "[[javascript:alert(\"Boo!\")|Click]]")
|
@@ -708,6 +708,7 @@ describe TracWiki::Parser do
|
|
708
708
|
|
709
709
|
it 'should parse image' do
|
710
710
|
tc("<p><img src=\"image.jpg\"/></p>\n", "[[Image(image.jpg)]]")
|
711
|
+
tc("<p><img src=\"javascript%3Aimage.jpg\" alt=\"tag\"/></p>\n", "[[Image(javascript:image.jpg,alt=tag)]]")
|
711
712
|
tc("<p><img src=\"image.jpg\" alt=\"tag\"/></p>\n", "[[Image(image.jpg,alt=tag)]]")
|
712
713
|
tc("<p><img src=\"image.jpg\" width=\"120px\"/></p>\n", "[[Image(image.jpg, 120px )]]")
|
713
714
|
tc("<p><img src=\"image.jpg\" width=\"120px\"/></p>\n", "[[Image(image.jpg, \t120px )]]")
|
@@ -720,7 +721,7 @@ describe TracWiki::Parser do
|
|
720
721
|
tc("<p><img src=\"image.jpg\" valign=\"middle\"/></p>\n", "[[Image(image.jpg, middle)]]")
|
721
722
|
tc("<p><img src=\"image.jpg\" title=\"houhouhou\"/></p>\n", "[[Image(image.jpg, title=houhouhou)]]")
|
722
723
|
tc("<p><img src=\"image.jpg\" width=\"120px\"/></p>\n", "[[Image(image.jpg,width=120px)]]")
|
723
|
-
tc("<p><img src=\"image.jpg\" width=\"120
|
724
|
+
tc("<p><img src=\"image.jpg\" width=\"120%25\"/></p>\n", "[[Image(image.jpg, width=120%)]]")
|
724
725
|
tc("<p><img src=\"image.jpg\" style=\"margin:5\"/></p>\n", "[[Image(image.jpg,margin=5)]]")
|
725
726
|
tc("<p><img src=\"http://example.org/image.jpg\"/></p>\n", "[[Image(http://example.org/image.jpg)]]")
|
726
727
|
end
|