Properly escape \n and \r in IRCColourfulRCFeedFormatter
authorRyan Schmidt <skizzerz@skizzerz.net>
Wed, 20 Jan 2016 17:06:45 +0000 (11:06 -0600)
committerRyan Schmidt <skizzerz@skizzerz.net>
Wed, 20 Jan 2016 17:10:14 +0000 (11:10 -0600)
Right now it is possible to emit a raw \n or \r to the UDP feed by
encoding it as an HTML entity, e.g. &#10; This could be used for
arbitrary IRC command execution in bots which do not subsequently
perform their own escaping. This commit changes it so that entities are
decoded first before \n and \r are stripped.

Change-Id: I3f7005abded3fbafb586754d763a00a4018f0954

includes/rcfeed/IRCColourfulRCFeedFormatter.php

index 30be343..0efcebf 100644 (file)
@@ -123,10 +123,10 @@ class IRCColourfulRCFeedFormatter implements RCFeedFormatter {
         * @return string
         */
        public static function cleanupForIRC( $text ) {
-               return Sanitizer::decodeCharReferences( str_replace(
+               return str_replace(
                        array( "\n", "\r" ),
                        array( " ", "" ),
-                       $text
-               ) );
+                       Sanitizer::decodeCharReferences( $text )
+               );
        }
 }