Page MenuHomePhabricator

Don't add &nbsp; in <pre>
Closed, DuplicatePublicFeature

Description

Author: a.badger

Description:
We had a user cut and paste a template from our mediawiki installation end up with some strange non-space invisible characters today. We think the cut and paste is a bit obscure. (He's using vimperator on firefox and that seems to have been part of how this happens). However, looking at what caused the special characters we found that mediawiki is adding &nbsp; if it's preceded with certain special characters. This happens even if the text occurs in a <pre> tag which seem redundant in most cases and, in this case, leads to the cut and paste bug we observed.

The following code seems to be causing this:

from Parser::parse():

Clean up special characters, only run once, next-to-last before doBlockLevels

$fixtags = array(

  1. french spaces, last one Guillemet-left
  2. only if there is something before the space '/(.) (?=\\?|:|;|!|%|\\302\\273)/' => '\\1&nbsp;\\2',
  3. french spaces, Guillemet-right '/(\\302\\253) /' => '\\1&nbsp;', '/&nbsp;(!\s*important)/' => ' \\1', #Beware of CSS magic word

!important, bug #11874.
);

It would be great if this code was smart enough to not replace spaces with &nbsp; inside of a <pre>.


Version: unspecified
Severity: enhancement

Details

Reference
bz18469

Event Timeline

bzimport raised the priority of this task from to Low.Nov 21 2014, 10:37 PM
bzimport added a project: MediaWiki-Parser.
bzimport set Reference to bz18469.
bzimport added a subscriber: Unknown Object (MLST).

Wondering if this is still a problem.
This code is in includes/parser/Parser.php and is slightly different nowadays:

(In reply to Toshio Kuratomi from comment #0)

'/(.) (?=\\?|:|;|!|%|\\302\\273)/' => '\\1&nbsp;\\2',

Now: '/(.) (?=\\?|:|;|!|%|\\302\\273)/' => '\\1&#160;',

'/(\\302\\253) /' => '\\1&nbsp;',

Now: '/(\\302\\253) /' => '\\1&#160;',

Aklapper changed the subtype of this task from "Task" to "Feature Request".Feb 4 2022, 11:01 AM
Aklapper removed a subscriber: wikibugs-l-list.
matmarex subscribed.

(Closing as a duplicate of a newer task, because that one has a better description.)