jsonrpc: fix (odd) paths being passed to builtins methods #2312

Merged
merged 5 commits into from Feb 27, 2013

Conversation

Projects
None yet
2 participants
Owner

Montellese commented Feb 25, 2013

This is an attempt to fix http://trac.xbmc.org/ticket/14066. The problem is that JSON-RPC simply takes paths/strings passed in as parameters and passes them on to CBuiltins as string parameters. If a path contains a , (which is used as a separator for parameters) or a double quote (which is used to delimit a string), the call results in unexpected behaviour because the path/string parameter is not properly parsed by CBuiltins.

This fix adds an Escape() method to CBuiltins which escapes all backslashes and double quotes in a string with a backslash and adds double-quotes around the whole string. That way the resulting string can be safely passed as a parameter to any builtins method.

Can anyone think of other special characters that need escaping or special treatment or is this enough?

Member

jmarshallnz commented Feb 26, 2013

There should be an escape routine (or two) already - see ESCINFO handling and also the stuff in CFavourites. Would be good to unify where possible.

Owner

Montellese commented Feb 26, 2013

Thanks for the hint. Will see what existing solutions I can find and try to unify them if possible.

Owner

Montellese commented Feb 26, 2013

OK I've unified the implementation of my CBuiltins::Escape() and the existing CFavourites::Paramify into StringUtils::Paramify and added a unit test for it. Concerning $ESCINFO I wasn't 100% how it works and I didn't wanna mess around in that code.

eb41220, 4a420ea and 609522d would be backport candidates.

Member

jmarshallnz commented Feb 26, 2013

Looks good - agreed with backports.

@ghost ghost assigned Montellese Feb 27, 2013

Montellese added a commit that referenced this pull request Feb 27, 2013

Merge pull request #2312 from Montellese/14066_builtins_paths
jsonrpc: fix (odd) paths being passed to builtins methods

@Montellese Montellese merged commit 54430d3 into xbmc:master Feb 27, 2013

@Montellese Montellese deleted the Montellese:14066_builtins_paths branch Feb 27, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment