How can I prevent XPATH injection in the .NET Framework?
We were previously using string concatenation to build XPATH statements, but found that end users could execute some arbitrary XPATH. For example:
string queryValue = "pages[@url='" + USER_INPUT_VALUE + "']";
node = doc.DocumentElement.SelectSingleNode(queryValue);
Would it be sufficient to strip out single and double quotes from input strings?
Or, does the .NET framework support parameterized XPATH queries?