Skip to main content
Participating Frequently
March 23, 2011
Question

NativeProcessStartupInfo.arguments escaping issue

  • March 23, 2011
  • 3 replies
  • 1373 views

Hi,

I've been using the NativeProcess class to call Java to calculate an MD5 hash of (large) files by passing File.nativePath as one of the arguments. When the file name has some strange character in it like "" (3 bytes: [EF][80][A0]), this character seems to be transformed by the escaping of NativeProcessStartupInfo.arguments to "?".

The NativeProcessStartupInfo.arguments documentation states: "AIR automatically      escapes any characters in the string that need to be escaped (such as space characters)." It seems to me that the escaping goes a little bit too far and escapes characters that shouldn't be escaped.

As a work-around I am Base64 encoding the path before I use it as an argument to pass to Java. In Java I decode the path and all works as expected.

I'm using AIR 2.5, below is a code snippet of how I make the call to Java:

var args:Vector.<String> = new Vector.<String>();
args.push("-cp");

args.push("path to jar");

args.push("class to execute");
args.push("filePath");

var info:NativeProcessStartupInfo = new NativeProcessStartupInfo();
info.executable = [javaLocation];
info.arguments = args;

javaProcess = new NativeProcess();
[adding all listeners...]
javaProcess.start(info);

Has anyone else encountered this problem? Is this considered expected behavior?

Cheers,

Wijnand

This topic has been closed for replies.

3 replies

Inspiring
August 10, 2015

I can confirm this issue.

I've recently run into the same problem as I tried to pass a string (path to a file) containing a space char to a batch/cmd file (in order to pass an argument with space chars to a batch file, you need to quote it).

Workaround was to replace all occurences of the space char with a certain unique string (in this case I chose ${SPACE} ) and then parse ${SPACE} back to a space character inside the batch file. I therefore used the tool FART: Find And Replace Text

itlancer
Inspiring
July 23, 2015

I have the same problem with spaces in file pathes. I still don't know how to avoid this issue with third party applications.

Wijnand_Author
Participating Frequently
April 5, 2011

Does anyone have any idea?