Subito-it / SBTUITestTunnelHost

Add Mac host tunnel to your XCTests

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Failed to execute command 'xcrun simctl openurl' when URL with two or more ampersand (&)

EgorovDmitry opened this issue · comments

Hi, I faced with an issue with open urls when this URL contains two or more ampersands (&), for example https://appenvironment.app.io/openspace.htm?acc=1005&path=inbox&ei=9130&et=task

The whole command looks like:
XCTestCase().host.executeCommand(xcrun simctl openurl 7A54E60C-296A-4238-A2A1-611D1B28A972 https://appenvironment.app.io/openspace.htm?acc=1005&path=inbox&ei=9130&et=task)

Open URL command works when I use a link with one ampersand, for example:
XCTestCase().host.executeCommand(xcrun simctl openurl 7A54E60C-296A-4238-A2A1-611D1B28A972 https://appenvironment.app.io/openspace.htm?acc=1005&path=inbox
but when I add the rest two parameters with ampersands my command hanging and failed with cause "The request timed out."

I tried to escape the sequence for these symbols but it still doesn’t work, could you help to figure out how can I pass these types of links

So, I guess, I found the root cause of this issue, the server application thinks that my link contains several commands united by "&", and tries to work with them, but receives a crash in the substring function.
I also found a temporary solution, I remove "&" from regex
let regex = try NSRegularExpression(pattern: ".*?(?:(;|&))", options: .caseInsensitive) in ExecHandler of SBTUITunnelHostServer project

and add escape the sequence, two backslashes (\) for every ampersand (&) in my link.

Thanks for letting me know, indeed those checks make the request fail as you described. This was a lousy way to check that no unwanted commands would be invoked from remote because at the beginning the connection was not binded to localhost. Since this is no longer the case we can remove all those checks altogether. I pushed some changes to https://github.com/Subito-it/SBTUITestTunnelHost/tree/feature/remove_token and will try to merge them in the coming days

Thank you for this amazing tool!
I have a question - will you update the binary for the new version? I downloaded version 2.0.0 and as I understand it has the old version of the binary file(1.2.0)

Instead of updating the binary, I've added a build script.