Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

metasync does not escape file names fully when querying amarok #2595

Closed
aranc23 opened this issue Jun 15, 2017 · 1 comment
Closed

metasync does not escape file names fully when querying amarok #2595

aranc23 opened this issue Jun 15, 2017 · 1 comment
Labels
bug bugs that are confirmed and actionable

Comments

@aranc23
Copy link

aranc23 commented Jun 15, 2017

Problem

The metasync plugin does not fully escape file names when querying amarok via dbus,
in particular it does not escape double quotes which means any files with " in them causes a dbus error.

Running this command in verbose (-vv) mode:

[accx@a-lnx005:~/src/beets] (metasync-fixes)$ ./beet -vv metasync stuck out here
user configuration: /home/accx/.config/beets/config.yaml
data directory: /home/accx/.config/beets
plugin paths: 
Sending event: pluginload
library database: /home/accx/beets.db
library directory: /data/music
Sending event: library_opened
Traceback (most recent call last):
  File "./beet", line 23, in <module>
    beets.ui.main()
  File "/home/accx/src/beets/beets/ui/__init__.py", line 1256, in main
    _raw_main(args)
  File "/home/accx/src/beets/beets/ui/__init__.py", line 1243, in _raw_main
    subcommand.func(lib, suboptions, subargs)
  File "/home/accx/src/beets/beetsplug/metasync/__init__.py", line 136, in func
    meta_source.sync_from_source(item)
  File "/home/accx/src/beets/beetsplug/metasync/amarok.py", line 74, in sync_from_source
    results = self.collection.Query(self.queryXML % escape(basename(path)))
  File "/home/accx/.local/lib/python2.7/site-packages/dbus/proxies.py", line 70, in __call__
    return self._proxy_method(*args, **keywords)
  File "/home/accx/.local/lib/python2.7/site-packages/dbus/proxies.py", line 145, in __call__
    **keywords)
  File "/home/accx/.local/lib/python2.7/site-packages/dbus/connection.py", line 651, in call_blocking
    message, timeout)
dbus.exceptions.DBusException: org.freedesktop.DBus.Error.InvalidArgs: Invalid XML: <query version="1.0">                     <filters>                         <and><include field="filename" value="24 - Beck - Untitled ("Stuck Out Here...").ogg" /></and>                     </filters>                 </query>

If I change the template for the XML query to dbus to use single quotes, then queries will fail when the file name contains single quotes.

The call to escape(basename(path))) on line 76 doesn't escape " or ' and it should probably do so?

In a sane world my files wouldn't contain double or single quotes but some do...

Setup

  • OS: Fedora (not relevant)
  • beets version 1.4.4
  • Python version 2.7.13

My configuration (output of beet config) is:

convert:
    dest: ~/PhoneSync/Music
    never_convert_lossy_files: yes
    formats:
        mp3: ffmpeg -i $source -y -vn -codec:a libmp3lame -qscale:a 1 $dest
        alac:
            command: ffmpeg -i $source -y -vn -acodec alac $dest
            extension: m4a
        aac:
            command: ffmpeg -i $source -y -vn -acodec aac -aq 1 $dest
            extension: m4a
        opus: ffmpeg -i $source -y -vn -acodec libopus -ab 96k $dest
        flac: ffmpeg -i $source -y -vn -acodec flac $dest
        ogg: ffmpeg -i $source -y -vn -acodec libvorbis -aq 3 $dest
        wma: ffmpeg -i $source -y -vn -acodec wmav2 -vn $dest
    album_art_maxwidth: 0
    format: mp3
    auto: no
    threads: 8
    copy_album_art: no
    tmpdir:
    max_bitrate: 500

    paths: {}
    pretend: no
    quiet: no
    embed: yes
metasync:
    source: amarok
    amarok:
        library: /home/accx/Music

plugins: info bpd convert play metasync
directory: /data/music

import:
    copy: no
    write: no
    log: ~/log/beets.log
play:
    command: /home/accx/deadbeef/deadbeef
    use_folders: no
    raw: no
    warning_threshold: 100
    relative_to:
library: ~/beets.db
bpd:
    volume: 100
    host: ''
    password: REDACTED
    port: 6600
@sampsyo sampsyo added the bug bugs that are confirmed and actionable label Jun 16, 2017
@sampsyo
Copy link
Member

sampsyo commented Jun 16, 2017

Oh dear! That won't do at all. Thanks for the thorough report!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug bugs that are confirmed and actionable
Projects
None yet
Development

No branches or pull requests

2 participants