Hi there,
I have a file with unicode characters I used url decoder code below on a large file, but what is funny is that it doesn't decode some lines,but when I use the code on a file with just that line it decodes it correctly.

import urllib.parse

for lines in open('mytxt1.txt'):
     s = urllib.parse.unquote(lines,encoding='latin-1')
     with open ('outtxt1.txt','a') as f1:
        f1.write(s)
        f1.close()

for example login=bob%40%3CSCRipt%3Ealert%28Paros%29%3C%2FscrIPT%3E.parosproxy.org is not decoded,
but when using just one line i get login=bob@<SCRipt>alert(Paros)</scrIPT>.parosproxy.org

It work's for me when i do a little test,using Pyhon 3.4.2.

mytxt1.txt:

http://ascii.cl?parameter=%22Click+on+%27URL+Decode%27%21%22
login=bob%40%3CSCRipt%3Ealert%28Paros%29%3C%2FscrIPT%3E.parosproxy.org
http://ascii.cl?parameter=%22Click+on+%27URL+Decode%27%21%22
login=bob%40%3CSCRipt%3Ealert%28Paros%29%3C%2FscrIPT%3E.parosproxy.org

outtxt1.txt:

http://ascii.cl?parameter="Click+on+'URL+Decode'!"
login=bob@<SCRipt>alert(Paros)</scrIPT>.parosproxy.org
http://ascii.cl?parameter="Click+on+'URL+Decode'!"
login=bob@<SCRipt>alert(Paros)</scrIPT>.parosproxy.org

I also use python 3.4
but my output file has a lot of % ,not decoded. The output is on this link!!

snippsat when I try the code on the whole file some lines are skipped!!!!!
Do u know what the problem is, can u try the whole file I attached, and see what's wrong, cause I need to try it on 5 other txt file.thx

ohhh...
the problem is when I encode
modo=registro%253CSCRIPT%253Ealert%2528%2522Paros%2522%2529%253B%253C%252FSCRIPT%253E
I get modo=registro%3CSCRIPT%3Ealert%28%22Paros%22%29%3B%3C%2FSCRIPT%3E
I got alot of these lines that need to be encoded tiwce,
but when I encode the output file once again I get some extra line!!!!!
th lines in two files are not the same.
any Idea???

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.