Page 1 of 2
Launch URL with tilde (~) [SOLVED]
Posted: Tue Jul 05, 2016 10:25 am
by Zax
Hello,
I have to launch an URL with a tilde in it, somethinh like
https://ssl15.ovh.net/~myDomain/myPage.html but the tilde character is transformed into the string "LE8B3" by the browser. Then, of course, the server returns a 404 error.
I used this:
Code: Select all
put "https://ssl15.ovh.net/~myDomain/myPage.html" into myURL // just an example
launch url myURL
I tried this, but it doesn't work:
Code: Select all
put "https://ssl15.ovh.net/~myDomain/myPage.html" into myURL // just an example
put textEncode(myUrl,"UTF-8") into myURL
launch url myURL
What should I do? Sorry if is has been already discussed somewhere.
Thank tou for your help.
Re: Launch URL with tilde (~) ?
Posted: Tue Jul 05, 2016 11:57 am
by jmburnod
Hi zak,
You can try this.
Code: Select all
put "https://ssl15.ovh.net/" & urlencode("~myDomain") & "/myPage.html" into myUrl
Best regards
Jean-Marc
Re: Launch URL with tilde (~) ?
Posted: Tue Jul 05, 2016 12:38 pm
by Zax
jmburnod wrote:Hi zak,
You can try this.
Code: Select all
put "https://ssl15.ovh.net/" & urlencode("~myDomain") & "/myPage.html" into myUrl
Best regards
Jean-Marc
Thanks for your quick answer.
I tried your solution but the browser has a strange behaviour:

As it's a private domain, names have been changed on the screen capture but the interesting thing is that when I click into the browser's URL field and press the return key, it goes to the correct URL. But when I simply reload the page, it returns the same 404 error.
Any Idea?
Re: Launch URL with tilde (~) ?
Posted: Tue Jul 05, 2016 5:46 pm
by jmburnod
What about this ?
Code: Select all
put urlEncode(textEncode("~myDomain","utf8")) into tDomain
put "https://ssl15.ovh.net/" & tDomain & "/myPage.html" into myUrl
Re: Launch URL with tilde (~) ?
Posted: Wed Jul 06, 2016 10:35 am
by MaxV
Mac OS encoding is MacRoman
Re: Launch URL with tilde (~) ?
Posted: Wed Jul 06, 2016 12:46 pm
by Zax
jmburnod wrote:What about this ?
Code: Select all
put urlEncode(textEncode("~myDomain","utf8")) into tDomain
put "https://ssl15.ovh.net/" & tDomain & "/myPage.html" into myUrl
I tried with "utf8" and "MacRoman" parameter but it stills doesn't work. The result in the same that shown in the posted screen capture.
I suppose I will have to use HTTP protocol, instead of HTTPS, in order to have a "regular" URL, without this damned tilde.
Anyhow, thanks for your suggestions.
Re: Launch URL with tilde (~) ?
Posted: Wed Jul 06, 2016 5:18 pm
by jacque
Try something like this:
Code: Select all
get "https://ssl15.ovh.net/~myDomain/myPage.html"
replace "~" with "%7e" in it
put it into tDomain
I couldn't test that because I don't have an example of a domain with a tilde, but that's the url encoding for it.
Re: Launch URL with tilde (~) ?
Posted: Thu Jul 07, 2016 8:41 am
by Zax
jacque wrote:Try something like this:
Code: Select all
get "https://ssl15.ovh.net/~myDomain/myPage.html"
replace "~" with "%7e" in it
put it into tDomain
Thank you Jacqueline, but it's always the same. I really don't understand where is the problem.
I also try with
before launch URL without any success.
Re: Launch URL with tilde (~) ?
Posted: Thu Jul 07, 2016 9:41 am
by [-hh]
You may try:
launch url ("
https://ssl15.ovh.net/"&numToChar(126)& ... yPage.html")
The problem could be that the tilde on your keyboard is generated not directly but for example by "option-n space". Some browsers (Firefox) correct this.
[The incorrect interpretation of your first post (E8B3) is an UTF-16 question mark, used for 'unknown chars'. So possibly your "tilde" is interpreted as UTF-16/two bytes.]
Re: Launch URL with tilde (~) ?
Posted: Thu Jul 07, 2016 11:49 am
by Zax
[-hh] wrote:You may try:
launch url ("
https://ssl15.ovh.net/"&numToChar(126)& ... yPage.html")
The problem could be that the tilde on your keyboard is generated not directly but for example by "option-n space". Some browsers (Firefox) correct this.
[The incorrect interpretation of your first post (E8B3) is an UTF-16 question mark, used for 'unknown chars'. So possibly your "tilde" is interpreted as UTF-16/two bytes.]
The URL that appears in Firefox is now:
https://ssl15.ovh.net/LE8B3myDomain/myPage.html
I also tried numToCodepoint(0x7e) with the same result.
Re: Launch URL with tilde (~) ?
Posted: Thu Jul 07, 2016 12:06 pm
by MaxV
What happen with this code
Code: Select all
put quote & "https://ssl15.ovh.net/~myDomain/myPage.html" & quote into myURL
put shell("/Applications/Firefox.app/Contents/MacOS/firefox " & myUrl)
??
Re: Launch URL with tilde (~) ?
Posted: Thu Jul 07, 2016 1:18 pm
by Zax
MaxV wrote:What happen with this code
Code: Select all
put quote & "https://ssl15.ovh.net/~myDomain/myPage.html" & quote into myURL
put shell("/Applications/Firefox.app/Contents/MacOS/firefox " & myUrl)
??
If Firefox is already launched, Message Box contains:
Message box wrote:2016-07-07 14:13:28.977 firefox[585:903] *** __NSAutoreleaseNoPool(): Object 0x1003cb500 of class NSCFDictionary autoreleased with no pool in place - just leaking
2016-07-07 14:13:28.980 firefox[585:903] *** __NSAutoreleaseNoPool(): Object 0x1003c14f0 of class NSCFArray autoreleased with no pool in place - just leaking
2016-07-07 14:13:34.248 firefox[585:903] *** __NSAutoreleaseNoPool(): Object 0x1003b8aa0 of class NSCFString autoreleased with no pool in place - just leaking
2016-07-07 14:13:34.645 firefox[585:903] Error loading /Library/ScriptingAdditions/QXPScriptingAdditions.osax/Contents/MacOS/QXPScriptingAdditions: dlopen(/Library/ScriptingAdditions/QXPScriptingAdditions.osax/Contents/MacOS/QXPScriptingAdditions, 262): no suitable image found. Did find:
/Library/ScriptingAdditions/QXPScriptingAdditions.osax/Contents/MacOS/QXPScriptingAdditions: no matching architecture in universal wrapper
firefox: OpenScripting.framework - scripting addition "/Library/ScriptingAdditions/QXPScriptingAdditions.osax" declares no loadable handlers.
I not, it works but it freezes LC.
Re: Launch URL with tilde (~) ?
Posted: Thu Jul 07, 2016 3:06 pm
by [-hh]
[Please tell us the versions you use: MacOS, Firefox, and LiveCode.]
This works (and also other 'usual solutions' above work)
with MacOS 10.9 to 10.12 in Safari, Firefox and Chrome and LC 6/7/8.
I tested all with LC-scripts and a real "tilde-URL".
Code: Select all
tell application "Safari" -- or "Firefox" or "Google Chrome"
open location "http://ssl15.ovh.net/%7EmyDomain/myPage.html"
-- open location "http://ssl15.ovh.net/~myDomain/myPage.html" -- works also
end tell
You could try it from the Applescript Editor to see if your LC version is the culprit. If not then you could try the different browsers if there are differences.
Re: Launch URL with tilde (~) ?
Posted: Thu Jul 07, 2016 3:51 pm
by FourthWorld
Here's some background on the use of tildes in URLs:
https://www.cs.tut.fi/~jkorpela/tilde.html
It would seem the initial translation of the tilde to anything other than its character entity equivalent is incorrect. That may be a bug in LC, or the CEF browser, or elsewhere. Are you using the most recent build of LC?
To get this working for now, Jacque's suggestion of replacing the tilde with its character entity form seems the simplest, and the most consistent with the recommendations of the relevant RFCs as noted in the article above.
Re: Launch URL with tilde (~) ?
Posted: Thu Jul 07, 2016 4:28 pm
by [-hh]
One could also use the *actual* RFC 3986 (2005)
http://www.rfc-editor.org/rfc/rfc3986.txt
There you'll find even the recommendation to replace -- vice versa -- occurrences of "%7E" with "~" in an URI:
RFC 3986 wrote:For consistency, percent-encoded octets in the ranges of
ALPHA (%41-%5A and %61-%7A), DIGIT (%30-%39), hyphen (%2D), period (%2E), underscore (%5F), or tilde (%7E)
should not be created by URI producers and, when found in a URI, should be decoded to their corresponding unreserved characters by URI normalizers.