CMakePP / CMakePPLang

Object-oriented extension to the CMake language.
http://cmakepp.github.io/CMakePPLang/
Apache License 2.0
11 stars 4 forks source link

Protect escaped chars in object method arguments #47

Closed zachcran closed 2 years ago

zachcran commented 2 years ago

Fixes #46, where escaped special characters were being deprotected as they passed through the various function calls made during the execution of an object method call. The solution to be implemented is to protect the special characters as soon as they are passed into the object method call as benign, untype-able (or at least not easily typed) ASCII characters, like ASCII character 7, the BEL character. Then, they will be decoded again immediately before execution.

Steps to complete this PR:

zachcran commented 2 years ago

So far, this PR handles ;$"\ characters. In creating it, I found that the following characters do not need to be escaped in a string: (){}#'@^/, and I made a test verifying each one. Of the handled characters (;$"\), only one backslash (\) is needed in the string, except for escaping backslashes themselves and escaping the dollar sign at the beginning of a variable dereference. Both of these situations need three backslashes before the character to escape properly. For example, This is a backslash: \\\\ will result in "This is a backslash: \", and This dereferences a variable, var: \\\${var} will result in "This dereferences a variable, var: ${var}".

zachcran commented 2 years ago

@ryanmrichard Do you know of other special characters that we should support? I couldn't find a comprehensive list anywhere.

ryanmrichard commented 2 years ago

@zachcran those are the only special characters that I can think of (and I too can't find a list)

zachcran commented 2 years ago

I almost forgot the integration tests. I will try incorporating this branch into CMaize and running those tests, as well as building some projects using CMaize with this branch.