Opened 9 years ago

Closed 6 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: master
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: yes
Easy pickings: UI/UX:

Description

Patch is attached.

Attachments (1)

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

Download all attachments as: .zip

Change History (8)

comment:1 Changed 9 years ago by Malcolm Tredinnick

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 Changed 9 years ago by Thomas Güttler

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?

Changed 9 years ago by Thomas Güttler

Attachment: 7025.diff added

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

comment:3 Changed 8 years ago by Thomas Güttler

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

comment:4 Changed 8 years ago by Karen Tracey

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 Changed 6 years ago by Luke Plant

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 Changed 6 years ago by Peter Baumgartner

Severity: Normal
Type: New feature

comment:7 Changed 6 years ago by Thomas Güttler

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