Cscott has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/286928

Change subject: WIP: Warn when editors use the deprecated <b/> hack.
......................................................................

WIP: Warn when editors use the deprecated <b/> hack.

Pages using self-closing tags in violation of the HTML5 parsing specification
will have their templates/pages added to a new tracking category.  After these
uses are fixed, we will change the sanitizer to be consistent with the
HTML5 parsing spec.

Note that we already don't allow the <b/> hack if tidy is disabled; it
is converted to "&lt;b/>".  It may be worth making the no-tidy and with-tidy
behavior consistent.

Change-Id: Ie1cf3aa40d5483bf395ece539f0240b694ff04ab
---
M includes/Sanitizer.php
1 file changed, 11 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/28/286928/1

diff --git a/includes/Sanitizer.php b/includes/Sanitizer.php
index d321e9f..f9eaede 100644
--- a/includes/Sanitizer.php
+++ b/includes/Sanitizer.php
@@ -453,7 +453,7 @@
         * @return string
         */
        public static function removeHTMLtags( $text, $processCallback = null,
-               $args = [], $extratags = [], $removetags = []
+               $args = [], $extratags = [], $removetags = [], $warnCallback = 
null
        ) {
                extract( self::getRecognizedTagData( $extratags, $removetags ) 
);
 
@@ -604,6 +604,16 @@
                                                        call_user_func_array( 
$processCallback, [ &$params, $args ] );
                                                }
 
+                                               if ( $brace == '/>' && !( 
isset( $htmlsingle[$t] ) || isset( $htmlsingleonly[$t] ) ) ) {
+                                                       // Eventually we'll 
just remove the self-closing
+                                                       // slash, in order to 
be consistent with HTML5
+                                                       // semantics.
+                                                       // $brace = '>';
+                                                       // For now, let's just 
warn authors to clean up.
+                                                       if ( is_callable( 
$warnCallback ) ) {
+                                                               
call_user_func_array( $warnCallback, [ 'deprecated-self-close-category' ] );
+                                                       }
+                                               }
                                                if ( !Sanitizer::validateTag( 
$params, $t ) ) {
                                                        $badtag = true;
                                                }

-- 
To view, visit https://gerrit.wikimedia.org/r/286928
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie1cf3aa40d5483bf395ece539f0240b694ff04ab
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Cscott <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to