diff options
| author | Michael Foster <savetheinternet@tinyboard.org> | 2013-07-31 06:40:57 -0400 |
|---|---|---|
| committer | Michael Foster <savetheinternet@tinyboard.org> | 2013-07-31 06:40:57 -0400 |
| commit | 439795e63b1468000992275320b6c7e3f43fa9c0 (patch) | |
| tree | 7e9445c1e5bd21c1856d098d2827ea4dc4ee59e8 | |
| parent | 317f616e822c4519c78ac068bb69d285955bb39e (diff) | |
Disallow board names which are too large for the filesytem to handle
| -rw-r--r-- | inc/mod/pages.php | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/inc/mod/pages.php b/inc/mod/pages.php index ab4cdaaf..08604039 100644 --- a/inc/mod/pages.php +++ b/inc/mod/pages.php @@ -446,6 +446,23 @@ function mod_new_board() { if (!preg_match('/^' . $config['board_regex'] . '$/u', $_POST['uri'])) error(sprintf($config['error']['invalidfield'], 'URI')); + $bytes = 0; + $chars = preg_split('//u', $_POST['uri'], -1, PREG_SPLIT_NO_EMPTY); + foreach ($chars as $char) { + $o = 0; + $ord = ordutf8($char, $o); + if ($ord > 0x0080) + $bytes += 5; // @01ff + else + $bytes ++; + } + $bytes + strlen('posts_.frm'); + + if ($bytes > 255) { + error('Your filesystem cannot handle a board URI of that length (' . $bytes . '/255 bytes)'); + exit; + } + if (openBoard($_POST['uri'])) { error(sprintf($config['error']['boardexists'], $board['url'])); } |
