TMSU icon indicating copy to clipboard operation
TMSU copied to clipboard

`tmsu tag -` scripting doesn't completely handle escaped spaces

Open 0ion9 opened this issue 8 years ago • 1 comments

Steps to reproduce:

  1. cd /tmp; tmsu init .
  2. touch "foo bar"
  3. tmsu tags "foo bar"
  4. (Result should be nothing)
  5. Create the file tscript
  6. Add this line exactly as shown: foo\ bar atag btag some\ other\ tag
  7. tmsu tag - < tscript
  8. tmsu tags "foo bar"
  9. (Result should be atag btag some\ other\ tag, but is nothing)

Here is another interesting case, B, that can be checked after the first one:

  1. touch foo
  2. Change tscript to read foo bar atag btag some\ other\ tag (this is intentionally ambiguous about filename)
  3. tmsu tag - < tscript
  4. tmsu tags foo
  5. (Result is nothing! As is the result for tmsu tags "foo bar", just to be complete.)

Just to verify that scripting works at all, I did echo "foo bar" | tmsu tag - -- this tagged foo with the tag bar, as expected.

I'm not 100% sure exactly what is happening here, particularly since the following case, C, demonstrates that some escape handling is being done.

  1. tmsu untag --all foo
  2. Change tscript to have two lines, the first reading foo bad\ line and the second reading foo goodline. Ensure the final line has a newline too (otherwise it won't be processed)
  3. tmsu tag - < tscript
  4. tmsu tags foo --> bad\ line goodline.. which is correct! (compare this with the failed case B.. line structure and contents only differ in that there are more tags AFAICS)

I have no more time to test right now, so I'll just note that using --verbose shows exactly what you would expect -- in the case where tags are applied, it's noted, and in the cases where they should but aren't, no attempt to apply them is made at all... and summarize:

  • It is possible to apply tags containing spaces, but not always (?)
  • It doesn't seem possible to apply tags to files whose names contain spaces, regardless of whether those spaces are escaped
  • When tags are successfully applied, escapes in tag names are correctly interpreted.
  • My best guess at cause is naive escape-unaware splitting of the line (this does not fully explain case B, though)

0ion9 avatar Jan 24 '17 04:01 0ion9

Thanks for reporting. I'll try to get this fixed soon.

oniony avatar Jan 26 '17 09:01 oniony