Bug 7123 - blank.png URL contains 2 slashes
: blank.png URL contains 2 slashes
Status: CLOSED FIXED
Product: Logitech Media Server
Classification: Unclassified
Component: Controller
: 7.0
: Macintosh Other
: -- normal (vote)
: ---
Assigned To: Andy Grundman
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2008-02-13 10:52 UTC by Andy Grundman
Modified: 2009-09-08 09:12 UTC (History)
3 users (show)

See Also:
Category: ---


Attachments
proposed patch (2.20 KB, text/plain)
2008-02-13 11:47 UTC, Andy Grundman
Details
simplified patch (1.94 KB, patch)
2008-02-13 13:34 UTC, Ben Klaas
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Andy Grundman 2008-02-13 10:52:55 UTC
 
Comment 1 Ben Klaas 2008-02-13 11:11:38 UTC
Andy, can you add a little context to this bug? I just put in some debug and I see this in SlimBrowser when requesting blank.png. Looks correct--

131003:4833 WARN (SlimBrowserApplet.lua:294) - /html/images/blank_56x56_p.png
Comment 2 Andy Grundman 2008-02-13 11:18:14 UTC
Yeah I'm doing a bit more debugging.  One interesting thing I see is that Jive is requesting the plugin icons wrong because they aren't defined with a leading slash:

GET plugins/Picks/html/images/icon_56x56_p.png HTTP/1.1
Accept-Language: en
Host: 192.168.100.12:9000
User-Agent: Jive/7.0 rexported
Client-Date: Wed, 13 Feb 2008 19:17:37 GMT

That's technically an invalid request even though it works.
Comment 3 Andy Grundman 2008-02-13 11:22:06 UTC
And here is what happens on SN, and that's where the double-slash comes in:

142112:1974 DEBUG (SlimServer.lua:678) - SlimServer {SqueezeNetwork}:fetchArtworkURL(http://www.beta.squeezenetwork.com:9000/plugins/Live365/html/images/icon.png)
142112:1974 DEBUG (SlimServer.lua:713) - ..fetching artwork
142112:1974 DEBUG (SlimServer.lua:678) - SlimServer {SqueezeNetwork}:fetchArtworkURL(http://www.beta.squeezenetwork.com:9000//html/images/blank.png)
Comment 4 Andy Grundman 2008-02-13 11:25:54 UTC
The problem is this line:

item["icon"] = 'http://' .. ip .. ':' .. port .. '/' .. item["icon"]

I can fix it in Jive but maybe the right thing to do is have a consistent format in SC and say that all icon URLs should have leading slashes.  That means fixing some web code because if I add a leading slash to plugin icons they no longer work in the web UI.
Comment 5 Andy Grundman 2008-02-13 11:34:23 UTC
Ben, please review this patch:

--- jive/share/applets/NowPlaying/NowPlayingApplet.lua	(revision 29295)
+++ jive/share/applets/NowPlaying/NowPlayingApplet.lua	(local)
@@ -151,7 +151,14 @@
 			if server:isSqueezeNetwork() then
 				-- Artwork on SN must be fetched as a normal URL
 				local ip, port = server:getIpPort()
-				item["icon"] = 'http://' .. ip .. ':' .. port .. '/' .. item["icon"]
+				
+				-- Bug 7123, Add a leading slash only if needed
+				local isAbsolute = string.find(item["icon"], '/')
+				if not isAbsolute or isAbsolute != 1 then
+					item["icon"] = '/' .. item["icon"]
+				end
+				
+				item["icon"] = 'http://' .. ip .. ':' .. port .. item["icon"]
 				server:fetchArtworkURL(item["icon"], icon, ARTWORK_SIZE)
 			else
 				server:fetchArtworkThumb(item["icon"], icon, _staticArtworkThumbUri, ARTWORK_SIZE)
Comment 6 Andy Grundman 2008-02-13 11:47:34 UTC
Created attachment 2871 [details]
proposed patch

Here is the full patch I think we need.  This fixes the non-absolute requests for plugin icons by checking for leading slashes everywhere one of these artwork URLs is generated (we should refactor this so it's not all over the place...)

Can you guys review?
Comment 7 Andy Grundman 2008-02-13 11:48:06 UTC
CC Richard and Dean for review.
Comment 8 Ben Klaas 2008-02-13 13:27:37 UTC
patch looks fine to me.

Lua has support for the ^ designation for "start of string", so this

local isAbsolute = string.find(artworkUri, '/')
if not isAbsolute or isAbsolute != 1 then
      artworkUri = '/' .. artworkUri
end

can be simplified to

if not string.find(artworkUri, "^/") then
      artworkUri = "/" .. artworkUri
end
Comment 9 Andy Grundman 2008-02-13 13:31:19 UTC
OK right, the manual isn't real clear that all those string functions take a pseudo-regex.
Comment 10 Ben Klaas 2008-02-13 13:32:12 UTC
yeah, they call them "magic characters". fancy. :)

Comment 11 Ben Klaas 2008-02-13 13:34:30 UTC
Created attachment 2874 [details]
simplified patch
Comment 12 Andy Grundman 2008-02-13 13:37:48 UTC
Fixed in r1943.
Comment 13 Chris Owens 2008-03-07 09:03:33 UTC
This bug is being closed since it was resolved for a version which is now released!  Please download the new version of SqueezeCenter (formerly SlimServer) at http://www.slimdevices.com/su_downloads.html

If you are still seeing this bug, please re-open it and we will consider it for a future release.