Execute plugin handling ampersands in torrent names: windows

Suggest, post, or discuss plugins for Deluge
Post Reply
TheShanMan
Leecher
Leecher
Posts: 56
Joined: Sun Jun 23, 2013 4:16 pm

Execute plugin handling ampersands in torrent names: windows

Post by TheShanMan »

From what I can tell, the execute plugin doesn't properly escape ampersands ("&") found in a torrent name and therefore my batch file is failing. I checked the deluge log file to see if it could show exactly what the plugin is using as the command line but it doesn't (at least at default logging level).

Does the execute plugin escape the ampersand?

Is there a way to see exactly what command line is being used for a given torrent?
TheShanMan
Leecher
Leecher
Posts: 56
Joined: Sun Jun 23, 2013 4:16 pm

Re: Execute plugin handling ampersands in torrent names: win

Post by TheShanMan »

Wondering about this limitation again. I'm tempted to download source and attempt a fix. Could a fix potentially be committed into the source repository? Hoping to get tentative approval since that would help motivate me to go to the trouble.
Cas
Top Bloke
Top Bloke
Posts: 3679
Joined: Mon Dec 07, 2009 6:04 am
Location: Scotland

Re: Execute plugin handling ampersands in torrent names: win

Post by Cas »

The torrent name is utf8 encoded, it is your script that needs to handle the filename correctly.
TheShanMan
Leecher
Leecher
Posts: 56
Joined: Sun Jun 23, 2013 4:16 pm

Re: Execute plugin handling ampersands in torrent names: win

Post by TheShanMan »

No, I'm not talking about encoding. I'm talking about escaping.
TheShanMan
Leecher
Leecher
Posts: 56
Joined: Sun Jun 23, 2013 4:16 pm

Re: Execute plugin handling ampersands in torrent names: win

Post by TheShanMan »

To expand on my prior post, I'm talking about escaping required by the Windows OS command line. Unless an ampersand is escaped, Windows interprets it as separating 2 commands, so it runs everything before the ampersand as one command and everything after it as another command (ref: http://www.robvanderwoude.com/condexec.php). So when the execute plugin tries to run a command and the filename has an ampersand in it, Windows tries to run it as 2 separate and partial commands.

I have tested my script by calling it manually, and if it is called with the ampersand properly escaped, my script works fine. So the problem isn't my script as you suggested. And it's not an encoding issue. It's a Windows-specific command line escaping issue with the plugin.

http://stackoverflow.com/questions/1402 ... -parameter
Cas
Top Bloke
Top Bloke
Posts: 3679
Joined: Mon Dec 07, 2009 6:04 am
Location: Scotland

Re: Execute plugin handling ampersands in torrent names: win

Post by Cas »

Ok that makes more sense now. It should be a case of double-quoting the parameters passed to getProcessOutputAndValue.
TheShanMan
Leecher
Leecher
Posts: 56
Joined: Sun Jun 23, 2013 4:16 pm

Re: Execute plugin handling ampersands in torrent names: win

Post by TheShanMan »

Cool. So then the question is how to move forward. Is that something you want to fix? If not, can I fix it and submit it for inclusion in future releases? I would prefer the former since I would have to ramp up on deluge development but if it'll only get done if I do it myself, I'm willing to give it a shot.
Cas
Top Bloke
Top Bloke
Posts: 3679
Joined: Mon Dec 07, 2009 6:04 am
Location: Scotland

Re: Execute plugin handling ampersands in torrent names: win

Post by Cas »

I can fix it but it's not something I will be fixing in the immediate future, especially since it's a Windows issue. It's up to you but Deluge development is fun ;)

Ticket so it doesn't get forgotten about: http://dev.deluge-torrent.org/ticket/2784
Post Reply