View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0001146 | mantisbt | bugtracker | public | 2001-11-13 22:40 | 2004-08-29 02:12 |
Reporter | prescience | Assigned To | thraxisp | ||
Priority | normal | Severity | minor | Reproducibility | N/A |
Status | closed | Resolution | fixed | ||
Fixed in Version | 0.19.0rc1 | ||||
Summary | 0001146: PRE tags in text | ||||
Description | The input system should deal with PRE tags better. Right now it does a double convert on the linefeeds ( through nl2br). | ||||
Tags | No tags attached. | ||||
Attached Files | pre.diff (890 bytes)
Index: core/string_api.php =================================================================== RCS file: /cvsroot/mantisbt/mantisbt/core/string_api.php,v retrieving revision 1.55 diff -u -r1.55 string_api.php --- core/string_api.php 22 Jul 2004 13:42:02 -0000 1.55 +++ core/string_api.php 30 Jul 2004 22:36:19 -0000 @@ -55,6 +55,15 @@ $p_string = string_preserve_spaces_at_bol( $p_string ); $p_string = nl2br( $p_string ); + # fix up eols within <pre> tags (#1146) + preg_match_all("/<pre[^>]*?>(.|\n)*?<\/pre>/", $p_string, $pre1); + for ($x = 0; $x < count($pre1[0]); $x++) { + $pre2[$x] = preg_replace("/<br[^>]*?>/", "", $pre1[0][$x]); + $pre2[$x] = preg_replace("/([^\n]{".$wrap."})(?!<\/pre>)/", "$1\n", $pre2[$x]); + $pre1[0][$x] = "/" . preg_quote($pre1[0][$x], "/") . "/"; + } + $p_string = preg_replace($pre1[0], $pre2, $p_string); + return $p_string; } | ||||
I'd like to second this! I tried a pre tag over multiple lines and ended up with a blank line inbetween each 'real' line (because both the newline and br tags cause a new line). When I edited the HTML so that it read something like 'this is line one(br)this is line two' (which isn't pretty in any case) the input system worked the first time - (IE the br tag worked) but whenever I went to edit whatever I had just posted it had removed the br tag! FYI browser is IE4.0 (no chance of upgrading) :( and Mantis version is 0.17.3 edited on: 07-03 02:21 |
|
This will fix it. Just replace the nl2br() call in core/string_api.php with the following function: function nl2br_pre($string, $wrap = 80) {
} |
|
Bug 3656, which I submitted a little while ago, is a duplicate of this. Sorry about that. |
|
hacker's patch works great. would be nice if it were integrated into mantis... |
|
That patch didn't work for me. I used the search pattern '|{pre}.*?{/pre}|is' (where the { brackets are actually < brackets - sorry!) instead and it was fine. edited on: 06-08-04 10:38 |
|
When I use <b>hacker</b>'s function I get the following error: <B>SYSTEM NOTICE: Undefined vasriable: pre2</b> Where do I define this variable for usage? NOTE: I placed the function in the top of the core\strings_api.php edited on: 06-10-04 12:39 |
|
virtuetek, looks like you cut-and-pasted wrong. Check the code again, $pre2 is defined there. |
|
<pre>
</pre> Looks ok to me. <b>When I add a new variable to mantis....does it need to be pre-defined somewhere else in the code? edited on: 06-12-04 23:18 |
|
In fixing this, I noticed that string_display is used for virtually all text fields, including those (like title) that probably shouldn't have html in them in the first place. Is this a concern? |
|
thraxisp - from your last comment, did you have a patch for this seperate to notes in the bugtracker? |
|
The attached patch is my suggested implementation. |
|
I applied the patch uploaded by thraxisp after fixing a couple of notices.
Also I added this in a separate method called string_nl2br() which calls the standard nl2br(), then executes this custom code. Then changed string_display() to use string_nl2br(). |
|