r42257 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r42256‎ | r42257 | r42258 >
Date:06:46, 20 October 2008
Author:krimpet
Status:old (Comments)
Tags:
Comment:
Convert literal tabs to 	 when passing them through Tidy, to prevent them from being clobbered.
Modified paths:
  • /trunk/phase3/includes/parser/Parser.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/parser/Parser.php
@@ -665,9 +665,14 @@
666666 */
667667 function tidy( $text ) {
668668 global $wgTidyInternal;
 669+
669670 $wrappedtext = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"'.
670671 ' "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html>'.
671672 '<head><title>test</title></head><body>'.$text.'</body></html>';
 673+
 674+ # Tidy is known to clobber tabs; convert 'em to entities
 675+ $wrappedtext = str_replace("\t", '&#9;', $wrappedtext);
 676+
672677 if( $wgTidyInternal ) {
673678 $correctedtext = self::internalTidy( $wrappedtext );
674679 } else {
@@ -677,6 +682,10 @@
678683 wfDebug( "Tidy error detected!\n" );
679684 return $text . "\n<!-- Tidy found serious XHTML errors -->\n";
680685 }
 686+
 687+ # Convert the tabs back from entities
 688+ $correctedtext = str_replace('&#9;', "\t", $correctedtext);
 689+
681690 return $correctedtext;
682691 }
683692

Follow-up revisions

RevisionCommit summaryAuthorDate
r77410Revert r42257 "Convert literal tabs to &#9; when passing them through Tidy, t...simetrical00:10, 29 November 2010

Comments

#Comment by Brion VIBBER (talk | contribs)   23:04, 23 October 2008

whee

There is a tiny possibility that this might clobber JS code in CDATA sections, but practically I think it will not be an issue. :) In that case the literal \t will probably be fine. ;)

#Comment by Platonides (talk | contribs)   23:10, 25 October 2008

This revision breaks <inputbox>, see bugzilla:16108.

What's it fixing? We have always had tabs on the wiki without this conversion.

#Comment by DieBuche (talk | contribs)   00:09, 29 November 2010

This is bad. There are a lot of elements which don't allow random text in them.

  • foo
    • will be "tidied" to
      • foo
#Comment by DieBuche (talk | contribs)   00:11, 29 November 2010

try again with

<pre>
<ul>
	<li>foo</li>
<ul>

will become

<ul>
<li style="list-style: none"></li>
<li>foo
</li>
</ul>
#Comment by Simetrical (talk | contribs)   00:12, 29 November 2010

Reverted in r42257.

#Comment by Simetrical (talk | contribs)   00:12, 29 November 2010

I mean, r77410. Ugh, the lack of edit functionality here is really annoying.

#Comment by P.Copp (talk | contribs)   00:31, 29 November 2010

FTR: The revision was meant to fix bug 15959, which I've reopened for now, although I don't think it's a big issue.

Status & tagging log