View Issue Details

IDProjectCategoryView StatusLast Update
0010956mantisbtbugtrackerpublic2009-10-07 14:19
Reportercmfitch1 Assigned Todhx  
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
Target Version1.2.0rc2Fixed in Version1.2.0rc2 
Summary0010956: string_nl2br() wraps in the middle of words for preformatted text
Description

The string_nl2br() function doesn't look for whitespace before wrapping a line when the text is in a

 block. I will attach a patch to correct this issue shortly. 

Tagspatch
Attached Files
issue_10956.patch (832 bytes)   
From 064a4a914f7d89ed0e5089f0d8d1d6ec9e39af8e Mon Sep 17 00:00:00 2001
From: Chris Fitch <cfitch@redcom.com>
Date: Thu, 17 Sep 2009 09:56:09 -0400
Subject: [PATCH] Fix line wrap regex for preformatted text


diff --git a/core/string_api.php b/core/string_api.php
index 3971dd2..f2b6614 100644
--- a/core/string_api.php
+++ b/core/string_api.php
@@ -106,7 +106,7 @@ function string_nl2br( $p_string, $p_wrap = 100 ) {
 				#     if other encoded characters are a problem
 				$piece = preg_replace( '/&nbsp;/', ' ', $piece );
 				if( ON == config_get( 'wrap_in_preformatted_text' ) ) {
-					$output .= preg_replace( '/([^\n]{' . $p_wrap . '})(?!<\/pre>)/', "$1\n", $piece );
+					$output .= preg_replace( '/([^\n]{' . $p_wrap . ',}?[\s]+)(?!<\/pre>)/', "$1\n", $piece );
 				} else {
 					$output .= $piece;
 				}
-- 
1.6.0.4

issue_10956.patch (832 bytes)   

Activities

cmfitch1

cmfitch1

2009-09-17 10:39

reporter   ~0022960

Oops. I shouldn't have used a pre tag to indicate "preformatted" in my description. Perhaps someone with edit permissions could fix that for me.

dhx

dhx

2009-09-22 03:21

reporter   ~0023003

Committed, thanks!

Related Changesets

MantisBT: master-1.2.x 694037a6

2009-09-17 09:56

Chris Fitch

Committer: dhx


Details Diff
Fix 0010956: Fix line wrap regex for preformatted text

The string_nl2br() function doesn't look for whitespace before wrapping
a line when the text is in a <pre> block.

Signed-off-by: David Hicks <hickseydr@optusnet.com.au>
Affected Issues
0010956
mod - core/string_api.php Diff File

MantisBT: master 0fd12b74

2009-09-17 09:56

Chris Fitch

Committer: dhx


Details Diff
Fix 0010956: Fix line wrap regex for preformatted text

The string_nl2br() function doesn't look for whitespace before wrapping
a line when the text is in a <pre> block.

Signed-off-by: David Hicks <hickseydr@optusnet.com.au>
Affected Issues
0010956
mod - core/string_api.php Diff File