visuald icon indicating copy to clipboard operation
visuald copied to clipboard

Fix Issue 21897 Semicolon inside quotes in path variable causes range violation in pipedmd

Open MetaLang opened this issue 3 years ago • 5 comments

https://issues.dlang.org/show_bug.cgi?id=21897

MetaLang avatar May 06 '21 17:05 MetaLang

If anyone can point out how I can add some tests for this case, please do so - it isn't immediately obvious.

MetaLang avatar May 06 '21 18:05 MetaLang

Not sure if it is worth the trouble, but ';' is a valid path character and is searched if it is specified in PATH with quotes. To mimick this behavior PATH should not be split simply by ; as done above the patch. This would also avoid the trouble with mismatched quotes in the report.

Skipping empty paths is fine (I guess this avoids the RangeError), but removing just a pair of quotes should be slightly more correct.

If anyone can point out how I can add some tests for this case, please do so - it isn't immediately obvious.

Sorry, there are no tests for pipedmd ATM.

rainers avatar May 07 '21 11:05 rainers

To mimick this behavior PATH should not be split simply by ; as done above the patch. This would also avoid the trouble with mismatched quotes in the report.

What would you suggest instead of splitting the path by ;? Splitting by ";?

Skipping empty paths is fine (I guess this avoids the RangeError), but removing just a pair of quotes should be slightly more correct.

I'm not clear on what you mean by this. Can you give an example?

MetaLang avatar May 11 '21 01:05 MetaLang

What would you suggest instead of splitting the path by ;? Splitting by ";?

I think that the splitting by ';' must not occur between matching quotes. To avoid that PATH has to be parsed manually.

I'm not clear on what you mean by this. Can you give an example?

I meant that quotes should only be removed as a pair at the beginning and the end of a path, e.g. for "c:\a\b", but not for "c:\a\b. Given the rule above that matching quotes are searched for anyway, it only makes a difference for the last quote without a match, and this actually seems to be removed by cmd. So strip is fine indeed. Actually, all quotes should be removed from the resulting path p.

rainers avatar May 11 '21 05:05 rainers

I have implemented proper path splitting here now: https://github.com/rainers/visuald/commit/c62c2cfd96c0e6cb944e4752fe7d78c041189b56

rainers avatar May 23 '21 08:05 rainers