Page MenuHomePhabricator

T130947-1.23.patch

Authored By
MaxSem
May 11 2016, 10:01 PM
Size
1 KB
Referenced Files
None
Subscribers
None

T130947-1.23.patch

From cabbb70d60d4300498182acb31e3959b9094e21e Mon Sep 17 00:00:00 2001
From: Max Semenik <maxsem.wiki@gmail.com>
Date: Wed, 11 May 2016 14:58:47 -0700
Subject: [PATCH] SECURITY: Wrap diff generation in PoolCounter
Bug: T130947
---
includes/diff/DifferenceEngine.php | 28 ++++++++++++++++++++++++++++
1 file changed, 28 insertions(+)
diff --git a/includes/diff/DifferenceEngine.php b/includes/diff/DifferenceEngine.php
index 410f5c9..6129b35 100644
--- a/includes/diff/DifferenceEngine.php
+++ b/includes/diff/DifferenceEngine.php
@@ -839,6 +839,34 @@ class DifferenceEngine extends ContextSource {
* @return bool|string
*/
public function generateTextDiffBody( $otext, $ntext ) {
+ $diff = function() use ( $otext, $ntext ) {
+ return $this->textDiff( $otext, $ntext );
+ };
+
+ $error = function( $status ) {
+ throw new FatalError( $status->getWikiText() );
+ };
+
+ // Use PoolCounter if the diff looks like it can be expensive
+ if ( strlen( $otext ) + strlen( $ntext ) > 20000 ) {
+ $work = new PoolCounterWorkViaCallback( 'diff',
+ md5( $otext ) . md5( $ntext ),
+ [ 'doWork' => $diff, 'error' => $error ]
+ );
+ return $work->execute();
+ }
+
+ return $diff();
+ }
+
+ /**
+ * Generates diff, to be wrapped internally in a logging/instrumentation
+ *
+ * @param string $otext Old text, must be already segmented
+ * @param string $ntext New text, must be already segmented
+ * @return bool|string
+ */
+ protected function textDiff( $otext, $ntext ) {
global $wgExternalDiffEngine, $wgContLang;
wfProfileIn( __METHOD__ );
--
2.7.2

File Metadata

Mime Type
text/x-diff
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3718107
Default Alt Text
T130947-1.23.patch (1 KB)

Event Timeline