XML parse can't deal with accented file name
#1
Hi.

Running XBMC 13.1, french users may have script error when :
- using a smart playlist named with accented characters, like Animés.xsp
- using Random And Last Items script addon (or any script that try to open an XML file with accented character using dom parser)

See line 847 :

http://xbmclogs.com/show.php?id=230286

This error cannot be fixed in Random And Last Items script but can be easily fixed by using .decode('utf-8') method to file object in expatbuilder.py.

Code:
def parse(file, namespaces=True):
    """Parse a document, returning the resulting Document node.

    'file' may be either a file name or an open file object.
    """
    if namespaces:
        builder = ExpatBuilderNS()
    else:
        builder = ExpatBuilder()

    if isinstance(file, StringTypes):
        fp = open(file.decode('utf-8'), 'rb')
        try:
            result = builder.parseFile(fp)
        finally:
            fp.close()
    else:
        result = builder.parseFile(file)
    return result

This kind of fix have to be done by XBMC team or dom parser team ?

Thanks.
Sorry for my english, but, you know, I'm French so ...

Main HTPC : Odroid-C2 running CoreELEC with Titan Bingie
Secondary HTPC : Freebox Mini 4K running Android TV with Titan Bingie
Reply
#2
python + windows + non-ascii = problems. It'll work fine under all other platforms, right?

BTW: can you not pass file.decode('utf-8') into the parse() function you list?
Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.


Image
Reply
#3
I will make some tests under Linux.

And I will have a look on using decode('utf-8') in Random And Last Items script went parsing XSP file.

EDIT : Adding decode('utf-8') to parse function in my script do the job

Will test this fix on OpenELEC.

Thanks.
Sorry for my english, but, you know, I'm French so ...

Main HTPC : Odroid-C2 running CoreELEC with Titan Bingie
Secondary HTPC : Freebox Mini 4K running Android TV with Titan Bingie
Reply

Logout Mark Read Team Forum Stats Members Help
XML parse can't deal with accented file name0