This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: patch for etree cdata and attr quoting
Type: Stage:
Components: XML Versions: Python 2.5
process
Status: closed Resolution: wont fix
Dependencies: Superseder:
Assigned To: effbot Nosy List: chrism, effbot, georg.brandl
Priority: normal Keywords:

Created on 2006-02-04 18:23 by chrism, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
betterescape.patch chrism, 2006-02-04 20:23
Messages (6)
msg27438 - (view) Author: Chris McDonough (chrism) Date: 2006-02-04 18:23
Attached is a patch for ElementTree (based on a checkout from the SVN 
trunk's xmlcore.etree) that seems to perform better escaping of cdata and 
attribute values.  Instead of replacing, for example "&quote;" with 
"&quote;" or "&" with "&", it tries to avoid requoting 
ampersands in things that look like entities.

Sorry, I haven't tested this with anything except Python 2.4, I'm not quite 
sure what to do about _encode_entity, and I haven't patched any tests or 
written a new one for this change.  Consider this more of a RFC than a 
patch ready-for-submission as a result.
msg27439 - (view) Author: Chris McDonough (chrism) Date: 2006-02-04 18:26
Logged In: YES 
user_id=32974

Sorry, the tracker doesn't seem to want to allow me to upload the file.  See 
http://www.plope.com/static/misc/betterescape.patch for the patch.
msg27440 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2006-02-04 18:29
Logged In: YES 
user_id=1188172

OP: You did check the box?
msg27441 - (view) Author: Chris McDonough (chrism) Date: 2006-02-04 20:23
Logged In: YES 
user_id=32974

Egads, I did this time.
msg27442 - (view) Author: Fredrik Lundh (effbot) * (Python committer) Date: 2006-02-06 21:55
Logged In: YES 
user_id=38376

I'm not sure I follow.  ET works on the infoset side of
things, where everything is decoded into Unicode strings (or
compatible ASCII strings).  If you set an attribute to
"&" in the infoset, it *must* be encoded on the way out.  
If you want an ampersand, use "&".
msg27443 - (view) Author: Chris McDonough (chrism) Date: 2006-02-08 17:00
Logged In: YES 
user_id=32974

Doh, of course.  Sorry, I suspect I'll need to go to remedial XML class.  Ignore 
this.
History
Date User Action Args
2022-04-11 14:56:15adminsetgithub: 42871
2006-02-04 18:23:43chrismcreate