679
Comment:
|
981
table for unquoting entities?
|
Deletions are marked like this. | Additions are marked like this. |
Line 18: | Line 18: |
html_escape_table = { "&": "&", '"': """, "'": "'", ">": ">", "<": "<" } |
html_escape_table = \ {"&": "&", '"': """, "'": "'", ">": ">", "<": "<"} |
Line 27: | Line 27: |
l=[] | L=[] |
Line 29: | Line 29: |
l.append( html_escape_table.get(c,c) ) return "".join(l) |
L.append(html_escape_table.get(c,c)) return "".join(L) |
Line 35: | Line 35: |
(none yet) | LionKimbro: Is there anything in the standard library for going the other way? Is there something where you can give it "&" and get back "&"? Perhaps in the XML libraries? I looked, but did not see anything. DOM, SAX- wouldn't be there. Not exactly XML-RPC either. Anyone know? [[Date(2005-06-10T16:35:16Z)]] |
Escaping HTML
The cgi module that comes with Python has an escape function:
However, it doesn't escape characters beyond &, <, and >.
Here's a small snippet that will let you escape those as well:
Discussion
LionKimbro: Is there anything in the standard library for going the other way? Is there something where you can give it "&" and get back "&"? Perhaps in the XML libraries? I looked, but did not see anything. DOM, SAX- wouldn't be there. Not exactly XML-RPC either. Anyone know? Date(2005-06-10T16:35:16Z)