There is a known issue in Shoutcast XML where when a certain Apple Useragent is used, it produces an XML error. This is passed to the Drupal Shoutcast module as well and when someone connects to the stream with that specific Apple device, it produces the following error on the site:

warning: simplexml_load_string() [function.simplexml-load-string]: Entity: line 1: parser error : Input is not proper UTF-8, indicate encoding ! Bytes: 0xA0 0x54 0x56 0x3B in modules/shoutcast/shoutcast.module on line 496.

While this is not an error with the Drupal Shoutcast module itself, has anyone came up with a patch that will either rewrite the useragent string to be valid XML, or at least ignore the string so that the error is not produced and therefore breaking the module during the time in which that person is connected?

The Apple useragent that is responsible is something like: AppleCoreMedia/1.0.0.9A406a (Apple in...

Comments

yohnson’s picture

Assigned: Unassigned » yohnson
Status: Active » Patch (to be ported)
Issue tags: +Apple TV, +user agent
StatusFileSize
new1.05 KB

Apple TV on the iOS5 has a user agent string that makes parsing the user agent string without some level of sanitation cause an error.

(Apple�TV; U; CPU OS 5_0_1 like Mac OS X; en_us)

Attached is a patch using the PHP function utf8_encode() around the user agent string.

yohnson’s picture

StatusFileSize
new1.05 KB

Prior patch attachment is missing a ) in the array definition edited. Revised patch attached

marty.true’s picture

I tried the second patch and it failed...

patching file shoutcast.module
Hunk #1 FAILED at 1.
Hunk #2 FAILED at 435.
2 out of 2 hunks FAILED -- saving rejects to file shoutcast.module.rej
root@server23 [/domain/sites/all/modules/shoutcast]# 
marty.true’s picture

I just manually changed the code in the shoutcast.module from your patch file and I think that worked okay. I'll post back if I find that it didn't work.

Thanks for the contrib! This has been a major pain!

marty.true’s picture

I applied the code in the patch and unfortunately I got this error this morning...

warning: simplexml_load_string() [function.simplexml-load-string]: ^ in /mysite/sites/all/modules/shoutcast/shoutcast.module on line 496.
warning: simplexml_load_string() [function.simplexml-load-string]: Entity: line 1: parser error : Input is not proper UTF-8, indicate encoding ! Bytes: 0xA0 0x54 0x56 0x3B in /mysite/sites/all/modules/shoutcast/shoutcast.module on line 499.

Disregard, I just downloaded the shoutcast.module file and found that for some reason, it had reverted back to original. I have inserted the patch code again and will monitor to see if it is working properly...

marty.true’s picture

After monitoring this for several weeks, I have still had instances where the Apple user agent still creates the issue...

marty.true’s picture

Any progress on fixing the broken XML that is generated from the "Bad Apple" user agent string that brings this module to its knees? Would love to have this fixed so that I don't keep having to keep kicking people off my stream in order to have the module displaying the information normally.

yohnson’s picture

Please upload a sample of XML source from your shoutcast server. Use this URL to retrieve the XML needed to debug this issue, make sure there is an instance of the user string causing issues present in the XML

http://host:port/admin.cgi?mode=viewxml