Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!
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.
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.
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.
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 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.]
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.
[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".
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.
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.
Richard Gaskin LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
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.