Tk Library Source Code

View Ticket
Login
Ticket UUID: 1742078
Title: html::nl2br procedure bug
Type: Bug Version: None
Submitter: jgodfrey Created on: 2007-06-23 14:10:59
Subsystem: html Assigned To: welch
Priority: 5 Medium Severity:
Status: Closed Last Modified: 2013-07-04 17:25:18
Resolution: Not Applicable Here Closed By:
    Closed on:
Description:
The "html::nl2br" procedure is designed to replace all line-endings with the HTML <br> construct.  It appears to be missing a common line-ending combo.  Here's the original procedure:

proc ::html::nl2br {s} {
    return [string map [list \n\r <br> \n <br> \r <br>] $s]
}

It's missing a substitution of the common "\r\n" combo.  Ultimately, the current procedure replaces that combo with 2 <br>'s, which is incorrect.  Now, maybe the existing "\n\r" is just transposed by accident, as that seems odd anyway...

I'd suggest the following replacement if that's the case:

proc ::html::nl2br {s} {
    return [string map [list \r\n <br> \n <br> \r <br>] $s]
}

Jeff