Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.Sign up
CUtil::ValidatePath fix double (back)slash check #15499
Very simple patch for correct double (back)slash path validation. This is only used by the function called from Python (xbmc.validatePath), all others in code assume false and skip this section. That is probably why this has been unnoticed for such a long time, but an user of my add-on tried to validate a path like this against it: nfs://184.108.40.206//video/Test/test.avi. The current situation returns 'nfs://220.127.116.11' instead of the full path with only the doubles removed. Of course it seems unnecessary to use the function at all, but it's nice to have it fixed anyway (or it should be removed if obsolete).
When we're looking at the previous commit, already 5 years ago, it seems clear that .Delete(x) has been replaced by .erase(x). However that Delete function used to call erase(x, length) with a default value of 1 for length. So that's when this bug got introduced. Simply adding a length of 1 to the erase() function will fix this.
This is my first PR on this repo, so hopefully I've done nothing wrong ;-) Otherwise, please forgive me.
Welcome to the repo! :-)
Please do not delete the PR template that we provide, but fill it out instead.
Code looks fine (I didn't investigate the logic yet) - two things that I would like to see:
@pkerling Thanks for your instructions. Sorry for deleting the template, I just looked at some other PR and didn't see it, so I though for such a simple patch it wasn't needed. Do you want me to provide it anyway, or is it fine to left it out for this one?
I've added some more detail to the commit message, so it's more clear what it does.
The PR template is mostly for new contributors (such as yourself) to make sure you know about our submission process etc. In fact, you would have seen the "I have added tests to cover my change" point in the checklist if you had used it.
Even a one-line change in an innocent-looking utility function can kill the whole application :-)
Just make sure to read it through next time.
What I meant was that you should add a unit test to our test suite so that we never regress on the correct behavior by accident. You can add it to this file: https://github.com/xbmc/xbmc/blob/master/xbmc/test/TestUtil.cpp - it should be mostly self-explanatory from reading the code that is there but do ask if you need any help.