r45417 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r45416‎ | r45417 | r45418 >
Date:15:59, 5 January 2009
Author:simetrical
Status:ok
Tags:
Comment:
Refactor somewhat so that escapeId() works right

r45267 commented out the logic prohibiting numbers and so on at the
start of id's. I've uncommented this logic, but passed 'noninitial' as
an option to escapeId() in all necessary circumstances. Shouldn't
change behavior, this is to simplify some further work I'm about to do.
Modified paths:
  • /trunk/phase3/includes/Sanitizer.php (modified) (history)
  • /trunk/phase3/includes/Title.php (modified) (history)
  • /trunk/phase3/includes/parser/Parser.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/parser/Parser.php
@@ -3618,7 +3618,7 @@
36193619 # Save headline for section edit hint before it's escaped
36203620 $headlineHint = $safeHeadline;
36213621 $safeHeadline = Sanitizer::escapeId( $safeHeadline,
3622 - $wgEnforceHtmlIds ? array() : 'xml' );
 3622+ $wgEnforceHtmlIds ? 'noninitial' : 'xml' );
36233623 # HTML names must be case-insensitively unique (bug 10721)
36243624 $arrayKey = strtolower( $safeHeadline );
36253625
@@ -4688,7 +4688,7 @@
46894689 # Strip out wikitext links(they break the anchor)
46904690 $text = $this->stripSectionName( $text );
46914691 return '#' . Sanitizer::escapeId( $text,
4692 - $wgEnforceHtmlIds ? array() : 'xml' );
 4692+ $wgEnforceHtmlIds ? 'noninitial' : 'xml' );
46934693 }
46944694
46954695 /**
Index: trunk/phase3/includes/Sanitizer.php
@@ -620,7 +620,7 @@
621621 if ( $attribute === 'id' ) {
622622 global $wgEnforceHtmlIds;
623623 $value = Sanitizer::escapeId( $value,
624 - $wgEnforceHtmlIds ? array() : 'xml' );
 624+ $wgEnforceHtmlIds ? 'noninitial' : 'xml' );
625625 }
626626
627627 // If this attribute was previously set, override it.
@@ -806,18 +806,11 @@
807807 $id = urlencode( Sanitizer::decodeCharReferences( strtr( $id, ' ', '_' ) ) );
808808 $id = str_replace( array_keys( $replace ), array_values( $replace ), $id );
809809
810 - /*
811 - // Let's not go changing our links just yet, since we plan to
812 - // rip this out anyway and switch to the prettier Unicode-friendly
813 - // links as XHTML and HTML 5 allow and browsers seem to think is
814 - // just a-ok to do.
815 - //
816810 if ( !preg_match( '/^[a-zA-Z]/', $id )
817811 && !in_array( 'noninitial', $options ) ) {
818812 // Initial character must be a letter!
819813 $id = "x$id";
820814 }
821 - */
822815 return $id;
823816 }
824817
Index: trunk/phase3/includes/Title.php
@@ -457,7 +457,7 @@
458458 # one version of Opera 9.x. The W3C validator, for one, doesn't seem
459459 # to care if they aren't encoded.
460460 return Sanitizer::escapeId( $fragment,
461 - $wgEnforceHtmlIds ? array() : 'xml' );
 461+ $wgEnforceHtmlIds ? 'noninitial' : 'xml' );
462462 }
463463
464464 #----------------------------------------------------------------------------

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r45267Partial revert of r45109, r45116 -- removing the forced 'x' prefix from IDs n...brion00:46, 1 January 2009

Status & tagging log