November 18, 2014

When is a Hyphen not a Hyphen?

Take a look at these 2 command line strings:
CASE 1:
"%windir%\Microsoft.NET\Framework\v2.0.50727\caspol.exe" -machine -addgroup All_Code 
-site 192.168.45.111 FullTrust -name "XXX : 192.168.45.111" -description 
"Allows full trust privileges to XXX Public Safety Applications"
CASE 2:
"%windir%\Microsoft.NET\Framework\v2.0.50727\caspol.exe" -machine -addgroup All_Code 
-site 192.168.45.111 FullTrust –name "XXX : 192.168.45.111" –description 
"Allows full trust privileges to XXX Public Safety Applications"

While the first one succeds the 2nd one fails. When we converted the "-name" in the first one to hex we got
2D6E616D65
Whereas in the second we got
966E616D65

The hyphen in the first is a hyphen but in the second one it is in fact a "non-breaking hyphen". This is just visible in this email but in a notepad editor they may look exactly the same.
The morale of the story is: Beware of command line arguments copied from 3rd party sources

No comments: