Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F9001
StripLoopLimited.patch
Public
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Authored By
•
bzimport
Nov 22 2014, 12:14 AM
2014-11-22 00:14:51 (UTC+0)
Size
1 KB
Referenced Files
None
Subscribers
None
StripLoopLimited.patch
View Options
Index: includes/parser/StripState.php
===================================================================
--- includes/parser/StripState.php (revision 114159)
+++ includes/parser/StripState.php (working copy)
@@ -87,16 +87,29 @@
*/
protected function unstripType( $type, $text ) {
// Shortcut
- if ( !count( $this->data[$type] ) ) {
+ $numbStripItems = count( $this->data[$type] );
+ if ( $numbStripItems === 0 ) {
return $text;
}
wfProfileIn( __METHOD__ );
$this->tempType = $type;
- do {
+
+ // Only do unstrip a max of $numbStripItems.
+ // Most of the time, this loop would only be
+ // needed to execute once, but in the worst
+ // case it might need to be executed once for
+ // each item. Limitting to $numbStripItems
+ // prevents someone from maliciously making
+ // cyclic strip item references. (bug 35315)
+ for ( $i = 0; $i < $numbStripItems; $i++ ) {
$oldText = $text;
$text = preg_replace_callback( $this->regex, array( $this, 'unstripCallback' ), $text );
- } while ( $text !== $oldText );
+ if ( $text === $oldText ) {
+ // No changes so we can exit the loop
+ break;
+ }
+ }
$this->tempType = null;
wfProfileOut( __METHOD__ );
return $text;
File Metadata
Details
Attached
Mime Type
text/x-diff
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
8516
Default Alt Text
StripLoopLimited.patch (1 KB)
Attached To
Mode
T37315: XSS in CharInsert, forged strip markers
Attached
Detach File
Event Timeline
Log In to Comment