job-queue insert should no longer fail for highly used templates (bug 5527)
[lhc/web/wiklou.git] / includes / OutputHandler.php
index b530b0a..2b3e9fa 100644 (file)
@@ -102,7 +102,12 @@ function wfGzipHandler( $s ) {
  * Mangle flash policy tags which open up the site to XSS attacks.
  */
 function wfMangleFlashPolicy( $s ) {
-       return preg_replace( '/\<\s*cross-domain-policy\s*\>/i', '<NOT-cross-domain-policy>', $s );
+       # Avoid weird excessive memory usage in PCRE on big articles
+       if ( preg_match( '/\<\s*cross-domain-policy\s*\>/i', $s ) ) {
+               return preg_replace( '/\<\s*cross-domain-policy\s*\>/i', '<NOT-cross-domain-policy>', $s );
+       } else {
+               return $s;
+       }
 }
 
 /**