xbmc/xbmc — pull request #2312 by Montellese (2013-02-25 22:50:03+00:00)
Title: jsonrpc: fix (odd) paths being passed to builtins methods

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?