Skip to content

Commit

Permalink
Fixes #112 check_encoding() can cause timeouts
Browse files Browse the repository at this point in the history
  • Loading branch information
JN-Jones committed Sep 9, 2014
1 parent b510247 commit 965c29b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 3 additions & 0 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
define("IN_MYBB", 1);
define("WRITE_LOGS", 1);
define("TIME_NOW", time());
// The encoding detection can cause timeout errors and is automatically skipped for larger strings
// However this may also happen on smaller strings - set this to 1 if you have that problem
define("SKIP_ENCODING_DETECTION", 1);

if(function_exists('date_default_timezone_set') && !ini_get('date.timezone'))
{
Expand Down
2 changes: 1 addition & 1 deletion resources/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -859,7 +859,7 @@ function check_encoding($string, $encoding)
}

// These functions can have significant load or crash if the string passed is too long.
if(strlen($string) < 1024*5)
if(SKIP_ENCODING_DETECTION != 1 && strlen($string) < 1024*5)
{
return (preg_match('#^(?:
[\x09\x0A\x0D\x20-\x7E]
Expand Down

0 comments on commit 965c29b

Please sign in to comment.