View Issue Details

IDProjectCategoryView StatusLast Update
0021410mantisbtuipublic2016-08-28 01:12
Reportergeoff@streeter.gr Assigned Todregad  
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
OSLinuxOS VersionKubuntu 14.04 
Product Version1.2.3 
Target Version1.3.1Fixed in Version1.3.1 
Summary0021410: text looks OK in edit of note but renders badly
Description

text looks OK in edit of note but renders badly

Steps To Reproduce

Wrap

 <\pre> tags around the text in the file and use it as a note

TagsNo tags attached.
Attached Files
partner.desc (3,393 bytes)

Relationships

related to 0021594 new Improve display of 'pre' tags 

Activities

geoff@streeter.gr

geoff@streeter.gr

2016-07-22 09:09

reporter   ~0053689


Valid structures on a component:

  1. Normal: pointer inside name space points to its follow
    ┌───────────────────────────────────────────────┐
    │NSR FOLLOW │
    │ ↑ │
    │ * │
    └───────────────────────────────────────────────┘

  2. Acceptable: pointer inside name space points to its NSR
    ┌───────────────────────────────────────────────┐
    │NSR FOLLOW │
    │↑ │
    │* │
    └───────────────────────────────────────────────┘

  3. Pointer inside subspace points to its parent. Normal.
    ┌───────────────────────────────────────────────┐
    │NSR FOLLOW │
    │ ↑ │
    │ │ ┌───────┐ │
    │ └────────* │ │
    │ └───────┘ │
    │ │
    └───────────────────────────────────────────────┘

  4. Pointer inside subspace points to its parent. Acceptable.
    ┌───────────────────────────────────────────────┐
    │NSR FOLLOW │
    │↑ │
    ││ ┌───────┐ │
    │└────────* │ │
    │ └───────┘ │
    │ │
    └───────────────────────────────────────────────┘

  5. Pointer inside subspace points to another name space. Inside original,
    outside subspace. Normal.
    ┌───────────────────────────────────────────────┐
    │NSR FOLLOW │
    │ ┌───────────────┐ │
    │ ┌───────┐ │NSR FOLLOW │ │
    │ │ │ │↑ │ │
    │ │*───────────────┘ │ │
    │ └───────┘ └───────────────┘ │
    │ │
    └───────────────────────────────────────────────┘

  6. Pointer inside subspace points to another name space. Inside original,
    outside subspace. Acceptable.
    ┌───────────────────────────────────────────────┐
    │NSR FOLLOW │
    │ ┌───────────────┐ │
    │ ┌───────┐ │NSR FOLLOW │ │
    │ │ │ │ ↑ │ │
    │ │*──────────────────────┘ │ │
    │ └───────┘ └───────────────┘ │
    │ │
    └───────────────────────────────────────────────┘

geoff@streeter.gr

geoff@streeter.gr

2016-07-22 09:10

reporter   ~0053690

The incomplete boxes and extra lines are not supposed to be there.

cproensa

cproensa

2016-08-08 07:01

developer   ~0053757

The issue occurs at string_nl2br() function

Disabling wrapping pre text shows the correct line breaks:

$g_wrap_in_preformatted_text = OFF;

cproensa

cproensa

2016-08-08 08:45

developer   ~0053758

Last edited: 2016-08-08 08:46

this may fix it: note adding "u" as modifier for the regexp.


--- a/core/string_api.php
+++ b/core/string_api.php
@@ -123,7 +123,7 @@ function string_nl2br( $p_string, $p_wrap = 100 ) {

-$t_output .= preg_replace( '/([^\n]{' . $p_wrap . ',}?[\s]+)(?!<\/pre>)/', "$1\n", $t_piece );
+$t_output .= preg_replace( '/([^\n]{' . $p_wrap . ',}?[\s]+)(?!<\/pre>)/u', "$1\n", $t_piece );

seems like the 100 character count for line wrap is counted in bytes, for extended chars, unless the option is set?
I'm not such expert in regexp+unicode, anyone with better knwoledge can confirm?

dregad

dregad

2016-08-08 09:02

developer   ~0053759

Correct, without the 'u' flag, pcre treats strings as sequences of 1-byte chars.

IMO we should get rid of $g_wrap_in_preformatted_text, and add CSS 'overflow-x' attribute to 'pre' tags.

cproensa

cproensa

2016-08-09 07:49

developer   ~0053766

IMO we should get rid of $g_wrap_in_preformatted_text, and add CSS 'overflow-x' attribute to 'pre' tags.

Can we fix the 'u' in current 1.3.x
and remove the option in v2?

dregad

dregad

2016-08-09 09:41

developer   ~0053772

Follow-up issue: 0021594

Related Changesets

MantisBT: master-1.3.x ba89d0e1

2016-08-09 05:16

dregad


Details Diff
Prevent unwanted line breaks in <pre> tags

By default, Mantis wraps text within <pre> tags at 100 chars (see
$g_wrap_in_preformatted_text option).

If the text within the tag contains Unicode extended characters, the
regex performing the wrap does not count them properly, as pcre works on
bytes, causing line breaks to be added in the wrong place.

Adding 'u' modifier to the regex fixes the behavior, as suggested by
cproensa.

Fixes 0021410
Affected Issues
0021410
mod - core/string_api.php Diff File