MediaWiki r42257 - Code Review

Jump to: navigation, search
Repository:MediaWiki
Revision:r42256‎ | r42257 (on ViewVC)‎ | 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:

Diff [purge]

Index: trunk/phase3/includes/parser/Parser.php
===================================================================
--- trunk/phase3/includes/parser/Parser.php	(revision 42256)
+++ trunk/phase3/includes/parser/Parser.php	(revision 42257)
@@ -665,9 +665,14 @@
 	 */
 	function tidy( $text ) {
 		global $wgTidyInternal;
+
 		$wrappedtext = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"'.
 ' "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html>'.
 '<head><title>test</title></head><body>'.$text.'</body></html>';
+
+		# Tidy is known to clobber tabs; convert 'em to entities
+		$wrappedtext = str_replace("\t", '&#9;', $wrappedtext);
+
 		if( $wgTidyInternal ) {
 			$correctedtext = self::internalTidy( $wrappedtext );
 		} else {
@@ -677,6 +682,10 @@
 			wfDebug( "Tidy error detected!\n" );
 			return $text . "\n<!-- Tidy found serious XHTML errors -->\n";
 		}
+
+		# Convert the tabs back from entities
+		$correctedtext = str_replace('&#9;', "\t", $correctedtext);
+
 		return $correctedtext;
 	}
 

Follow-up revisions

Rev.Commit 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

  • 15:36, 12 September 2011 Meno25 (Talk | contribs) changed the status of r42257 [removed: reverted added: old]
  • 00:12, 29 November 2010 Simetrical (Talk | contribs) changed the status of r42257 [removed: ok added: reverted]
Personal tools
Namespaces
Variants
Views
Actions
Site
Support
Download
Development
Communication
Toolbox