manolomartinez / greg

A command-line podcast aggregator
GNU General Public License v3.0
297 stars 37 forks source link

Crash bug when quotes are in episode name: #39

Closed mfeif closed 8 years ago

mfeif commented 8 years ago
greg sync tnyrh
Checking tnyrh...
Downloading Episode 13: El Chapo v. Flores Brothers, and Jack Handey’s Santa Fe -- tnyradiohour011516_cms566193_pod.mp3
Traceback (most recent call last):
  File "/home/mjf/.local/bin/greg", line 9, in <module>
    load_entry_point('Greg==0.4.5', 'console_scripts', 'greg')()
  File "/home/mjf/.local/lib/python3.4/site-packages/greg/gregparser.py", line 113, in main
    args.func(vars(args))
  File "/home/mjf/.local/lib/python3.4/site-packages/greg/greg.py", line 764, in sync
    downloaded = feed.download_entry(entry)
  File "/home/mjf/.local/lib/python3.4/site-packages/greg/greg.py", line 325, in download_entry
    condition = filtercond(placeholders)
  File "/home/mjf/.local/lib/python3.4/site-packages/greg/greg.py", line 529, in filtercond
    return eval(condition)
  File "<string>", line 1
    "Episode" in "Episode 12: Sarah Koenig on "Serial," and a Resilient Poet"
                                                    ^
SyntaxError: invalid syntax

Seems like quote character needs to escaped?

manolomartinez commented 8 years ago

This is now fixed, but I need to think about the best way to sanitize strings in placeholders. Anyway, please confirm that it's now working.

Thanks, Manolo

mfeif commented 8 years ago

That's not a placeholder, that's the title of a feed entry. Or maybe I don't know what you mean? I presume if it's getting through feedparser, it's valid? I don't think we have to worry about SQL injection or such ;-)

Seems like the 'eval' is the problem? I haven't dug into greg's call tree enough to see why eval is needed.

ghost commented 8 years ago

If I do greg check -f tnyrh and then greg download 17 it works just fine for me:

Downloading Episode 12: Sarah Koenig on "Serial," and a Resilient Poet -- tnyradiohour010816_cms564184_pod.mp3

Does that part work for you? Or is this error only occurring when greg is run via cron?

mfeif commented 8 years ago

It does work with newest git-tip.

manolomartinez commented 8 years ago

That's not a placeholder, that's the title of a feed entry. Or maybe I don't know what you mean?

I meant you get to the offending string to be evaled, i.e.,

"Episode" in "Episode 12: Sarah Koenig on "Serial," and a Resilient Poet"

by taking the line you have in greg.conf (presumably something like filter = "Episode" in "{title}") and substituting the title of the feed entry for "{title}".

The resulting string is then evaluated to get a condition that greg uses to filter by. In the eval step the extra pair of quotes are making greg trip up. That's what I meant by sanitizing.

manolomartinez commented 8 years ago

I think this is solved, right? I will close it now, but do let me know if there's anything that needs to be ironed out.