<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -1,3 +1,8 @@
+2008-10-09 Dima Sabanin &lt;sdmitry@gmail.com&gt;
+  * Fixed display of images with special symbols in the name,
+    like '2777-nipple-+-apple-napple.jpg'. + is reserved by HTTP.
+    Now escaping filenames before giving them back in #public_path()
+
 2008-09-10 Norman Clarke &lt;norman@randomba.org&gt;
   * Fixed images not being converted to target format.
   </diff>
      <filename>CHANGELOG</filename>
    </modified>
    <modified>
      <diff>@@ -87,7 +87,13 @@ module HasImage
     #
     #   /photos/0000/0001/3er0zs.jpg
     def public_path_for(object, thumbnail = nil)
-      filesystem_path_for(object, thumbnail).gsub(/\A.*public/, '')
+      webpath = filesystem_path_for(object, thumbnail).gsub(/\A.*public/, '')
+      escape_file_name_for_http(webpath)
+    end
+    
+    def escape_file_name_for_http(webpath)
+      dir, file = File.split(webpath)
+      File.join(dir, CGI.escape(file))
     end
     
     # Deletes the images and directory that contains them.</diff>
      <filename>lib/has_image/storage.rb</filename>
    </modified>
    <modified>
      <diff>@@ -40,6 +40,24 @@ class StorageTest &lt; Test::Unit::TestCase
     assert_equal &quot;/tests/0000/0001/mypic_square.jpg&quot;, @storage.public_path_for(pic, :square)
   end
   
+  def test_public_path_for_image_with_html_special_symbols_in_name
+    @storage = HasImage::Storage.new(default_options.merge(:base_path =&gt; '/public'))
+    pic = stub(:has_image_file =&gt; &quot;my+pic&quot;, :has_image_id =&gt; 1)
+    assert_equal &quot;/tests/0000/0001/my%2Bpic_square.jpg&quot;, @storage.public_path_for(pic, :square)
+  end
+
+  def test_escape_file_name_for_http
+    @storage = HasImage::Storage.new(default_options.merge(:base_path =&gt; '/public'))
+    real = @storage.escape_file_name_for_http(&quot;/tests/0000/0001/mypic+square?something.jpg&quot;)
+    assert_equal &quot;/tests/0000/0001/mypic%2Bsquare%3Fsomething.jpg&quot;, real
+  end
+
+  def test_escape_file_name_for_http_escapes_only_filename
+    @storage = HasImage::Storage.new(default_options.merge(:base_path =&gt; '/public'))
+    real = @storage.escape_file_name_for_http(&quot;/tests/00+00/0001/mypic+square?something.jpg&quot;)
+    assert_equal &quot;/tests/00+00/0001/mypic%2Bsquare%3Fsomething.jpg&quot;, real
+  end
+  
   def test_filename_for
     @storage = HasImage::Storage.new(default_options)
     assert_equal &quot;test.jpg&quot;, @storage.send(:file_name_for, &quot;test&quot;)</diff>
      <filename>test/storage_test.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>192e1f1b0df26dd1d00d6f3d71cd4bec6c5e30e8</id>
    </parent>
  </parents>
  <author>
    <name>Dima Sabanin</name>
    <email>sdmitry@gmail.com</email>
  </author>
  <url>http://github.com/norman/has_image/commit/53888da5cd236bbbfdf9124f96ca2bbfececf4e7</url>
  <id>53888da5cd236bbbfdf9124f96ca2bbfececf4e7</id>
  <committed-date>2008-10-09T06:56:30-07:00</committed-date>
  <authored-date>2008-10-09T06:35:38-07:00</authored-date>
  <message>Fixed display of images with special symbols in the name,
like '2777-nipple-+-apple-napple.jpg'. + is reserved by HTTP.
Now escaping filenames before giving them back in #public_path()</message>
  <tree>e7acea62a1205ecf7e1a91628ebe21f1a62efdab</tree>
  <committer>
    <name>Dima Sabanin</name>
    <email>sdmitry@gmail.com</email>
  </committer>
</commit>
