trac-wiki 0.1.1 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -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=\"#{escape_html(uri)}\"#{make_image_attrs(attrs)}/>"
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]= escape_html($2)
232
+ a[$1]= escape_url($2)
233
233
  when /^(margin|margin-(left|right|top|bottom))=(\d+)$/
234
- style.push($1 + ":" + escape_html($3))
234
+ style.push($1 + ':' + escape_url($3))
235
235
  end
236
236
  end
237
237
  a['style'] = style.join(';') if ! style.empty?
@@ -1,3 +1,3 @@
1
1
  module TracWiki
2
- VERSION = '0.1.1'
2
+ VERSION = '0.1.2'
3
3
  end
@@ -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&quot;tag&quot;\"/></p>\n", "[[Image(image.jpg,alt=a\"tag\")]]")
453
- tc("<p><img src=\"image.jpg\" alt=\"a&quot;tag&quot;\"/></p>\n", "[[Image(image.jpg,alt=a\"tag\")]]", :no_link=>true)
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%\"/></p>\n", "[[Image(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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: trac-wiki
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: