ruby on rails - My app cannot load some images from the server -
i'm using ruby on rails on local webrick server.
i'm generating images of websites urls, writing them local filesystem, , displaying them. name images url replace \ -. images seem not loading because cannot find images on filesystem, , broken image icon. however, see images there when check filesystem.
this error in logs:
started "/images/image_site/http:--www.urbandictionary.com-define.php?term=slim%20shady.jpg?1309465379" 127.0.0.1 @ thu jun 30 13:23:06 -0700 2011 actioncontroller::routingerror (no route matches "/images/image_site/http:--www.urbandictionary.com-define.php"): this html code:
<img alt="http:--www.urbandictionary.com-define.php?term=slim%20shady" class="site_image" src="/images/image_site/http:--www.urbandictionary.com-define.php?term=slim%20shady.jpg?1309465379"> what going on , how can fix this? please let me know if need provide more information.
looks you're not encoding image names in src attribute. i'd guess have file name this:
http:--www.urbandictionary.com-define.php?term=slim%20shady.jpg but when have this:
src="/images/image_site/http:--www.urbandictionary.com-define.php?term=slim%20shady.jpg?1309465379" the filename looks this:
/images/image_site/http:--www.urbandictionary.com-define.php because after first ? considered part of query string.
replacing slashes hyphens not enough, you're still leaving sorts of holes confusion , nefarious intent. instead, should generate image file names completely, id.jpg id image's id in database. then, store original filename in database , show filename (properly encoded!) people, don't use in local file system.
a quick fix url encode src attributes. should fix how handle images or leave open sorts of trouble.
Comments
Post a Comment