Bug 5207 - I18n: Corrupt chars in Favorites
: I18n: Corrupt chars in Favorites
Status: CLOSED FIXED
Product: Logitech Media Server
Classification: Unclassified
Component: Web Interface
: 7.0
: PC Fedora
: P2 normal with 1 vote (vote)
: 7.6.0
Assigned To: Alan Young
: charset_issues, TestCase, test_automation
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2007-08-01 01:31 UTC by Real name
Modified: 2011-04-28 08:49 UTC (History)
2 users (show)

See Also:
Category: ---


Attachments
screenshot (5.82 KB, image/png)
2010-02-07 10:33 UTC, Real name
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Real name 2007-08-01 01:31:36 UTC
Repro steps:

1) Go to Browse/Favorites
2) Click "New Favorite"
3) In the Name field, type (copy/paste): Спутник
4) Click Save
5) The entry turns into "%u0421%u043F%u0443%u0442%u043D%u0438%u043A", but it should remain "Спутник"

Thanks.
Comment 1 Michael Herger 2007-08-02 03:47:41 UTC
Same as 5173 (https://bugs-archive.lyrion.org/show_bug.cgi?id=5173)?
Comment 2 Real name 2007-08-02 10:07:31 UTC
Michael, this is not a duplicate - this is a new problem, specific to version 7. As I understand, the Favorites have been completely rewritten in version 7.

This bug:
- non-ASCII chars change to '%uXXXX' representation.

Bug #5173:
- non-ASCII chars are turned into ASCII (each UTF-8 octet becomes an ASCII character)
Comment 3 Chris Owens 2007-08-07 13:06:41 UTC
What codepage does Slimserver think it's running?  This information is at the bottom of the 'Server Settings' page in the Slimserver web ui.
Comment 4 Real name 2007-08-07 13:33:03 UTC
SlimServer Version: 7.0a1 - 12431 - RedHat - EN - utf8
Perl Version: 5.8.8 i386-linux-thread-multi
MySQL Version: 5.0.21-standard
Comment 5 Real name 2007-08-20 02:24:29 UTC
Alright, the fix in two parts:

1) In [Slim/Plugin/Favorites/HTML/EN/plugins/Favorites/html/favorites.js], replace all 'escape' calls with 'encodeURIComponent'. See [http://search.cpan.org/dist/URI/URI/Escape.pm] and [http://www.w3schools.com/jsref/jsref_encodeURIComponent.asp] for more info.

2) In [Slim/Web/HTTP.pm], need to replace:

    $value = Slim::Utils::Unicode::utf8on($value);
    $value = Slim::Utils::Unicode::utf8encode_locale($value);

with:

    $value = Slim::Utils::Unicode::decode($value);

According to [http://search.cpan.org/~dankogai/Encode-2.23/Encode.pm], 'encode' turns a string into octets. We need to turn octets into a string. Hence, decode is the right function to call.

Thanks.
Comment 6 Michael Herger 2007-08-20 02:38:25 UTC
That change to HTTP.pm is interesting. In fact I've been encountering another issue with corrupted characters (https://bugs-archive.lyrion.org/show_bug.cgi?id=5236) and proposed a similar "fix" to the guy reporting it (Hungarian). He's been happy so far. I'll have to take a closer look at this.
Comment 7 Real name 2007-08-20 02:54:04 UTC
Actually, the fix in HTTP.pm that I've suggested above is a reversal of  [http://svn.slimdevices.com/trunk/server/Slim/Web/HTTP.pm?rev=5919&view=rev]:

--------------
Revision 5919
Modified Sat Jan 28 13:37:34 2006 PST (18 months, 3 weeks ago) by dsully
File length: 60884 byte(s)
Diff to previous 5878

Bug: 2617
Description: Encode non-ascii paths correctly. 
--------------

After reading the description of bug #2617, I think the problem was bogus, and the change was misguided.
Thanks.
Comment 8 Real name 2007-08-20 23:23:29 UTC
There is a typo in Comment #5, I meant:

    $value = Slim::Utils::Unicode::utf8decode($value);

Thanks.
Comment 9 Michael Herger 2007-12-10 06:11:50 UTC
Can you still reproduce this issue with the latest SC7 nightly? I've been successfully testing with some German umlauts, Hebrew and Hungarian text. Even your cyrillic example was stored correctly. Can we close this bug?
Comment 10 Real name 2007-12-24 01:40:42 UTC
Michael, v7.0 is still broken as of 2007-12-23.

REPRO:

1. Go to Home->Favorites->Edit
2. Click "New Favorite"
3. Copy/paste "Спутник" into the Name field
4. Click "Save"
5. The new entry turns into gibberish "Спутник", however it should read "Спутник"

THE FIX:

1) In [/usr/lib/perl5/vendor_perl/Slim/Plugin/Favorites/HTML/EN/plugins/Favorites/html/favorites.js] replace all 'escape' calls with 'encodeURIComponent'. 

Note: According to [http://search.cpan.org/dist/URI/URI/Escape.pm], "Javascript has a function called escape() that produce the sequence "%uXXXX" for chars in the 256 .. 65535 range. This function has really nothing to do with URI escaping but some folks got confused since it "does the right thing" in the 0 .. 255 range. Because of this you sometimes see "URIs" with these kind of escapes."

2) In [/usr/lib/perl5/vendor_perl/Slim/Web/HTTP.pm], replace:
    $value = Slim::Utils::Unicode::utf8on($value);
with:
    $value = Slim::Utils::Unicode::utf8decode($value);

Note: Variable $value should be converted from bytes to Unicode characters. Simply marking the string of bytes as Unicode, will turn each byte into a separate Unicode character - which is wrong.

Thanks.
Comment 12 Michael Herger 2008-01-08 10:20:12 UTC
Can you still reproduce this? change 15871 might have fixed this.

BTW: isn't this a dupe of bug 6297?
Comment 13 Real name 2008-01-08 11:11:19 UTC
Michael, yes, change 15871 fixes this particular bug 6297. However, it is wrong in general: the plugin code should use strings as is, not decode them. Currently, the parameter value containing Unicode characters is passed around as raw bytes (against Perl support for Unicode) and then it has to be converted as the value is needed.

The parameter value should be converted (utf8decode) once from raw bytes to UTF8 when it is read into the Perl realm (in HTTP.pm), and then used as a regular Perl string.

Please undo change 15871, and apply the fix as described in Comment #10
Comment 14 Michael Herger 2008-01-08 11:32:00 UTC
Is your problem fixed?
Comment 15 Real name 2008-01-08 12:20:57 UTC
Well, you seem to disregard my comments. I'll get back to you later.
Comment 16 Michael Herger 2008-01-09 00:44:03 UTC
I'm sorry you felt disregarded. I might have been a bit tired last night...

Please give change 16051 another try. It should fix this issue as well as some others which have repeatedly cropped up. Thanks for insisting ;-)
Comment 17 KDF 2008-01-10 08:15:40 UTC
16051 has broken the artwork param in Nokia770 skin. investigating for more details.
Comment 18 KDF 2008-01-10 08:37:34 UTC
param is now fixed at change 16106
Comment 19 Chris Owens 2008-03-07 09:04:16 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.
Comment 20 Real name 2010-02-07 10:33:15 UTC
Created attachment 6499 [details]
screenshot

a repro screenshot
Comment 21 Real name 2010-02-07 10:34:37 UTC
Still broken after I reported it 3 years ago. Some things change, some don't..

--------
Version: 7.4.1 - r28947 @ Tue Oct 20 08:13:15 PDT 2009
Operating system: Windows Home Server - EN - cp1252
Platform Architecture: 586
Perl Version: 5.10.0 - MSWin32-x86-multi-thread
MySQL Version: 5.0.22-community-nt
Comment 22 Chris Owens 2010-03-22 08:04:48 UTC
QA to reproduce
Comment 23 Chris Owens 2010-05-20 13:49:20 UTC
Michael, I'm assigning this to you for now.  It is reproducible on 7.5.1 r30796 on my Windows 7 system.

Note, looking at the comments, it looks as though this is one of the bugs that is connected to one or more bugs in a way that fixing one breaks the other, so please act with caution!
Comment 24 Alan Young 2011-01-20 00:05:57 UTC
Tested as working in 7.6 under Linux.
Comment 25 SVN Bot 2011-01-20 00:07:51 UTC
 == Auto-comment from SVN commit #31786 to the slim repo by ayoung ==
 == http://svn.slimdevices.com/slim?view=revision&revision=31786 ==

Fixed bug 5207: I18n: Corrupt chars in Favorites
Comment 26 Paul Chandler 2011-04-28 08:49:29 UTC
Verified on 7.6.0 (r 32366) on XP with SB Toucch


(In reply to comment #25)
> == Auto-comment from SVN commit #31786 to the slim repo by ayoung ==
>  == http://svn.slimdevices.com/slim?view=revision&revision=31786 ==
> 
> Fixed bug 5207: I18n: Corrupt chars in Favorites