Taiko2k/Tauon

Incorrect encoding of the <location> tag in the XSPF playlists

Opened this issue · 6 comments

Tauon Music Box should export XSPF playlists with the <location> tag encoded according to the Spec (6.2 Relative paths
):

Generators should take extra care to ensure that relative paths are correctly encoded. Do:

<location>My%20Song.flac</location>

Don’t:

<location>My Song.flac</location>

xport.write('      <location>' + escape(path) + '</location>\n')

and escape is

def escape(data, entities={}):
    """Escape &, <, and > in a string of data.

    You can escape other strings of data by passing a dictionary as
    the optional entities parameter.  The keys and values must all be
    strings; each key will be replaced with its corresponding value.
    """

    # must do ampersand first
    data = data.replace("&", "&amp;")
    data = data.replace(">", "&gt;")
    data = data.replace("<", "&lt;")
    if entities:
        data = __dict_replace(data, entities)
    return data

should urllib.parse.quote urllib.parse.quote(path)be used instead of escape(path)?

should urllib.parse.quote urllib.parse.quote(path)be used instead of escape(path)?

Yeah seems so.

I wanted to fix this issue but I did not understand how to build and test and currently I am on windows.

There's a guide in the github wiki, but it's a little involved.

I wanted to fix this issue but I did not understand how to build and test and currently I am on windows.

@prathamnagpure, I don't know if it's possible on Windows, but on Linux I was able to modify t_main.py in the already installed Tauon to test your solution. It seems that it works: Tauon creates XSPF playlists with the properly encoded <location> tag.

The source isn't easily edited in the Windows build as it's bundled into an exe.

This fix looks pretty straightforward though, I'll accept it as a PR.