or the full line:
How can I url encode this with JS and then safely decode it with PHP using
My program is writing URL-encoded strings into a text file like this one.
However, I'm trying to reverse the process by opening the same file and breaking that file up in a manner that I can retrieve into name/value-like pairs.
' Final Challenge Category Dim sr As StreamReader = New StreamReader("./Game" + nudGameNo.Value.ToString() + "/Final/category.txt") strLine = WebUtility.UrlDecode(sr.ReadLine)
The closest function that I can find to help is
HttpUtility.ParseQueryString but I can't seem to run it in a
WinForms application. (Even if I use
I've also tried to do a
& being the separator, however problems start up if a particular value contains an
& of it's own.
Is it possible to break this form of string up?
import reimport urllibimport HTMLParserurlRegex = re.compile(r'(.+)&data=')match=urlRegex.search('https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Foffice.memoriesflower.com%2FPermission%2F%2525%2524%255E%2526%2526*%2523%2523%255E%2524%2525%255E%2526%255E*%2526%2523%255E%2525%2525%2526%2540%255E*%2523%2526%255E%2525%2523%2526%2540%2525*%255E%2540%255E%2523%2525%255E%2540%2526%2525*%255E%2540%2Foffice.php&data=01%7C01%7Cdavid.levin%40mheducation.com%7C0ac9a3770fe64fbb21fb08d50764c401%7Cf919b1efc0c347358fca0928ec39d8d5%7C0&sdata=PEoDOerQnha%2FACafNx8JAep8O9MdllcKCsHET2Ye%2B4%3D&reserved=0')x = match.group()urlRegex_1 = re.compile(r'url=(.+)&data=')match_1 = urlRegex_1.search(x)print match1.group(1)htmlencodedurl = urllib.unquote(urllib.unquote(match1.group(1)))actual_url = HTMLParser.HTMLParser().unescape(htmlencodedurl)
So the 'actual_url' displays this:'https://office.memoriesflower.com/Permission/%$^&&##^$%^&^&#^%%&@^*#&^%'
I need it to display this:
$url = "https%3A%2F%2Fwww.MYWEBSITENAME.in%2F%27;%3Cinput%20autofocus%20onfocus=alert(document.domain)%3E";$url = urldecode($url);$urld = htmlentities(urlencode($url));header("location:".'http://MYREDIRECTLOCATION&id=111&pname=myproductname&url='.$urld);
// output of htmlentities(urlencode )) is https%3A%2F%2Fwww.MYWEBSITENAME.in%2F%27%3B%3Cinput+autofocus+onfocus%3Dalert%28document.domain%29%3E
My question is how can I stop browser from converting %3E to > and %3C to <, I tried htmlentities but didn't work!
There is a question here on stack overflow that answers PART of my question (see link)https://stackoverflow.com/a/17431971/2461910
Unfortunately, this solution is cumbersome, because it always encodes/decodes the ENTIRE current document.
I tried using
Editor.currentView.selected, but that throws an error when the script runs. If only I could find a document describing what all functions objects and properties are visible to the jN plugin. I suppose that's a topic for another question. Oh well.