Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

[#28912] Simplified regex to prevent stack overflow on long strings

  • Loading branch information...
commit 08cc05bbe8340a27c5a1a8c8a7c0ef122c045283 1 parent c34d397
@pjwiseman authored
Showing with 4 additions and 1 deletion.
  1. +4 −1 libraries/joomla/language/language.php
View
5 libraries/joomla/language/language.php
@@ -824,7 +824,7 @@ protected function parse($filename)
// Initialise variables for manually parsing the file for common errors.
$blacklist = array('YES', 'NO', 'NULL', 'FALSE', 'ON', 'OFF', 'NONE', 'TRUE');
- $regex = '/^(|(\[[^\]]*\])|([A-Z][A-Z0-9_\-\.]*\s*=(\s*(("([^"]|\\\")*")|(_QQ_)))+))\s*(;.*)?$/';
+ $regex = '/^(|(\[[^\]]*\])|([A-Z][A-Z0-9_\-\.]*\s*=(\s*(("[^"]*")|(_QQ_)))+))\s*(;.*)?$/';
$this->debug = false;
$errors = array();
@@ -842,6 +842,9 @@ protected function parse($filename)
// Check that the key is not in the blacklist and that the line format passes the regex.
$key = strtoupper(trim(substr($line, 0, strpos($line, '='))));
+ // Workaround to reduce regex complexity when matching escaped quotes
+ $line = str_replace('\"', '_QQ_', $line);
+
if (!preg_match($regex, $line) || in_array($key, $blacklist))
{
$errors[] = $lineNumber;
Please sign in to comment.
Something went wrong with that request. Please try again.