Opened 16 years ago

Closed 13 years ago

#7025 closed New feature (wontfix)

SafeUnicode.split() should return a list of SafeUnicode objects

Reported by: Thomas Güttler Owned by: nobody
Component: Core (Other) Version: dev
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: yes
Easy pickings: no UI/UX: no

Description

Patch is attached.

Attachments (1)

7025.diff (3.3 KB ) - added by Thomas Güttler 16 years ago.
Improved patch: Overwrite splitlines() and not split()

Download all attachments as: .zip

Change History (8)

comment:1 by Malcolm Tredinnick, 16 years ago

Patch needs improvement: set
Triage Stage: UnreviewedAccepted

If I do something like this

SmartUnicode(u"<").split("l")

the first component is no longer safe, since it contains an unescaped ampersand.

You might be able to come up with some extra logic to work around all those possibilities, but it might also end up making the resulting function a lot slower. Probably worth it if you can work around those cases without too much penalty, though.

See what you can come up with.

comment:2 by Thomas Güttler, 16 years ago

Yes, Mallcolm, you are right. I updated my patch. It now overwrites splitlines() (that's what I intended with split()).
The patch overwrites strip, rstrip and lstrip, too. And it includes a unittest.

There is still a rare condition where splitlines() can fail: Inside a CDATA section. But I think it is safe to ignore this.

Do you still think this patch needs improvement?

by Thomas Güttler, 16 years ago

Attachment: 7025.diff added

Improved patch: Overwrite splitlines() and not split()

comment:3 by Thomas Güttler, 16 years ago

Cc: hv@… removed
Resolution: wontfix
Status: newclosed

comment:4 by Karen Tracey, 16 years ago

Patch needs improvement: unset
Resolution: wontfix
Status: closedreopened

It is unclear why this was closed wontfix. Malcolm accepted the ticket and asked for an improved patch, which was provided. Even if the original submitter is no longer able to pursue the problem, the improved patch should be considered to fix the reported problem (since accepting implies the problem is real), correct?

comment:5 by Luke Plant, 13 years ago

Patch needs improvement: set

If there are cases where splitlines can fail to behave correctly with the proposed change, then we shouldn't do it, since it is security related (i.e. XSS attacks). The author didn't give a reason why we can safely ignore those circumstances. (Those circumstances being 'rare' isn't good enough, it needs to be 'never'). The other improvements (strip methods) are welcome though. Marking as 'needs improvement' on that basis.

comment:6 by Peter Baumgartner, 13 years ago

Severity: Normal
Type: New feature

comment:7 by Thomas Güttler, 13 years ago

Resolution: wontfix
Status: reopenedclosed

I (the original author of this ticket) will close this again: safestring.splitlines() ist not safe! Your content could include
CDATA sections with newlines. Please leave this closed.

Note: See TracTickets for help on using tickets.
Back to Top