Cscott has uploaded a new change for review.

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

Change subject: Prevent 100% CPU hang on certain input text.
......................................................................

Prevent 100% CPU hang on certain input text.

John Gruber's "Improved Liberal, Accurate Regex Pattern for Matching URLs"
(https://gist.github.com/gruber/249502) has four unnecessary `+` operators,
which cause O(N^4) performance regressions on certain inputs containing
parentheses.  This was causing a hang in the attributions of
[[:pt:Ficheiro:Joseph_Ducreux_(French_-_Self-Portrait,_Yawning_-_Google_Art_Project.jpg]]
 in a large book containing Portuguese articles on the human
sensory system.

Change-Id: I56890b98efbee3c05cbce1a125606bb03af07eb3
---
M lib/index.js
1 file changed, 2 insertions(+), 1 deletion(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Collection/OfflineContentGenerator/latex_renderer
 refs/changes/29/170329/1

diff --git a/lib/index.js b/lib/index.js
index 91d9410..28a4a6a 100644
--- a/lib/index.js
+++ b/lib/index.js
@@ -172,7 +172,8 @@
 ].join("\n");
 
 // John Gruber's "Improved Liberal, Accurate Regex Pattern for Matching URLs"
-var URL_REGEXP = 
/\b((?:[a-z][\w\-]+:(?:\/{1,3}|[a-z0-9%])|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}\/)(?:[^\s()<>]+|\((?:[^\s()<>]+|(?:\([^\s()<>]+\)))*\))+(?:\((?:[^\s()<>]+|(?:\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:'".,<>?«»“”‘’]))/i;
+// https://gist.github.com/gruber/249502
+var URL_REGEXP = 
/\b((?:[a-z][\w\-]+:(?:\/{1,3}|[a-z0-9%])|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}\/)(?:[^\s()<>]|\((?:[^\s()<>]|(?:\([^\s()<>]+\)))*\))+(?:\((?:[^\s()<>]|(?:\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:'".,<>?«»“”‘’]))/i;
 
 // Convert plain text (with HTML whitespace semantics) to an appropriately
 // escaped string for TeX to process.

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I56890b98efbee3c05cbce1a125606bb03af07eb3
Gerrit-PatchSet: 1
Gerrit-Project: 
mediawiki/extensions/Collection/OfflineContentGenerator/latex_renderer
Gerrit-Branch: master
Gerrit-Owner: Cscott <canan...@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to