Bug 13788 - URLs passed to image proxy need to be escaped
: URLs passed to image proxy need to be escaped
Status: CLOSED FIXED
Product: SqueezePlay
Classification: Unclassified
Component: API
: unspecified
: PC Other
: P1 normal (vote)
: 7.4.0
Assigned To: Andy Grundman
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2009-08-31 12:19 UTC by Andy Grundman
Modified: 2009-10-05 14:30 UTC (History)
4 users (show)

See Also:
Category: Bug


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andy Grundman 2009-08-31 12:19:49 UTC
For example, /public/imageproxy?w=180&h=180&f=&u=http://api.napster.com/cgi-bin/image-uri?type=track&id=28494546&country_code=GB

won't work.

Is there an existing way to URI-escape in our Lua code?
Comment 1 Ben Klaas 2009-08-31 12:32:47 UTC
To my knowledge we don't have anything, but I'm sure someone has written a lua function already that we could add to our jive.utils.string extension of the string library.

Assign to me as you see fit...
Comment 2 Ben Klaas 2009-08-31 12:35:07 UTC
from CGILua
http://www.keplerproject.org/cgilua/index.html#overview

----------------------------------------------------------------------------
-- Decode an URL-encoded string (see RFC 2396)
----------------------------------------------------------------------------
function unescape (str)
	str = string.gsub (str, "+", " ")
	str = string.gsub (str, "%%(%x%x)", function(h) return string.char(tonumber(h,16)) end)
	str = string.gsub (str, "\r\n", "\n")
	return str
end

----------------------------------------------------------------------------
-- URL-encode a string (see RFC 2396)
----------------------------------------------------------------------------
function escape (str)
	str = string.gsub (str, "\n", "\r\n")
	str = string.gsub (str, "([^0-9a-zA-Z ])", -- locale independent
		function (c) return string.format ("%%%02X", string.byte(c)) end)
	str = string.gsub (str, " ", "+")
	return str
end
Comment 3 Andy Grundman 2009-08-31 12:43:11 UTC
OK, that escape function looks good enough.  Do you want to add that?
Comment 4 Ben Klaas 2009-08-31 12:44:43 UTC
sure
Comment 5 SVN Bot 2009-08-31 13:28:28 UTC
 == Auto-comment from SVN commit #7344 to the jive repo by bklaas ==
 == https://svn.slimdevices.com/jive?view=revision&revision=7344 ==

Bug: 13788
Description: add string methods for urlEncode() and urlDecode()

lua files that use this must point to the extended string library like so
local string = require('jive.utils.string')
Comment 6 Ben Klaas 2009-08-31 13:31:11 UTC
back to you Andy
Comment 7 SVN Bot 2009-08-31 14:01:11 UTC
 == Auto-comment from SVN commit #7345 to the jive repo by andy ==
 == https://svn.slimdevices.com/jive?view=revision&revision=7345 ==

Fixed bug 13788, urlEncode imageproxy URL param
Comment 8 James Richardson 2009-10-05 14:30:52 UTC
This bug has been marked as fixed in the 7.4.0 release version of SqueezeBox Server!
    * SqueezeCenter: 28672
    * Squeezebox 2 and 3: 130
    * Transporter: 80
    * Receiver: 65
    * Boom: 50
    * Controller: 7790
    * Radio: 7790  

Please see the Release Notes for all the details: http://wiki.slimdevices.com/index.php/Release_Notes

If you haven't already, please download and install the new version from http://www.logitechsqueezebox.com/support/download-squeezebox-server.html

If you are still experiencing this problem, feel free to reopen the bug with your new comments and we'll have another look.