From daeef71d813b68524e0630e2aadbf0870bb06800 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Wed, 6 Dec 2006 15:47:50 +0000 Subject: some updater changes as well as tiny bugfixes git-svn-id: file:///svn/phpbb/trunk@6714 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/message_parser.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes/message_parser.php') diff --git a/phpBB/includes/message_parser.php b/phpBB/includes/message_parser.php index 797c2f5cfd..285b0d0649 100644 --- a/phpBB/includes/message_parser.php +++ b/phpBB/includes/message_parser.php @@ -418,7 +418,7 @@ class bbcode_firstpass extends bbcode $conf = array('highlight.bg', 'highlight.comment', 'highlight.default', 'highlight.html', 'highlight.keyword', 'highlight.string'); foreach ($conf as $ini_var) { - ini_set($ini_var, str_replace('highlight.', 'syntax', $ini_var)); + @ini_set($ini_var, str_replace('highlight.', 'syntax', $ini_var)); } // Because highlight_string is specialcharing the text (but we already did this before), we have to reverse this in order to get correct results -- cgit v1.2.1 From 1c41450bd90f86f47521952e7f48339f103b8e5d Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Fri, 8 Dec 2006 15:20:57 +0000 Subject: - re-add script_path for "strange configurations" to let them force the generated urls correctly - show rank title if no rank image present in memberlist - other fixes. git-svn-id: file:///svn/phpbb/trunk@6730 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/message_parser.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'phpBB/includes/message_parser.php') diff --git a/phpBB/includes/message_parser.php b/phpBB/includes/message_parser.php index 285b0d0649..ed6f69cf49 100644 --- a/phpBB/includes/message_parser.php +++ b/phpBB/includes/message_parser.php @@ -840,7 +840,14 @@ class bbcode_firstpass extends bbcode { global $config, $phpEx, $user; - $check_path = ($user->page['root_script_path'] != '/') ? substr($user->page['root_script_path'], 0, -1) : '/'; + if ($config['force_server_vars']) + { + $check_path = $config['script_path']; + } + else + { + $check_path = ($user->page['root_script_path'] != '/') ? substr($user->page['root_script_path'], 0, -1) : '/'; + } // Is the user trying to link to a php file in this domain and script path? if (strpos($url, ".{$phpEx}") !== false && strpos($url, $check_path) !== false) -- cgit v1.2.1 From 94476d05e09bcc70f4f2ea42472b5f22538f3235 Mon Sep 17 00:00:00 2001 From: David M Date: Sun, 10 Dec 2006 01:19:54 +0000 Subject: #6090 - some cool regex stuff (one of them looks kinda weird :\ ...) git-svn-id: file:///svn/phpbb/trunk@6735 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/message_parser.php | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) (limited to 'phpBB/includes/message_parser.php') diff --git a/phpBB/includes/message_parser.php b/phpBB/includes/message_parser.php index ed6f69cf49..561b2d79da 100644 --- a/phpBB/includes/message_parser.php +++ b/phpBB/includes/message_parser.php @@ -265,7 +265,7 @@ class bbcode_firstpass extends bbcode */ function bbcode_img($in) { - global $user, $config, $phpEx; + global $user, $config; if (!$this->check_bbcode('img', $in)) { @@ -309,7 +309,7 @@ class bbcode_firstpass extends bbcode */ function bbcode_flash($width, $height, $in) { - global $user, $config, $phpEx; + global $user, $config; if (!$this->check_bbcode('flash', $in)) { @@ -940,7 +940,8 @@ class parse_message extends bbcode_firstpass // Do some general 'cleanup' first before processing message, // e.g. remove excessive newlines(?), smilies(?) // Transform \r\n and \r into \n - $match = array('#\r\n?#', "#([\n][\s]+){3,}#u", '#(script|about|applet|activex|chrome):#i'); + // TODO: Second regex looks wrong... + $match = array('#\r\n?#', "#(\n\s+){3,}#u", '#(script|about|applet|activex|chrome):#i'); $replace = array("\n", "\n\n", "\\1:"); $this->message = preg_replace($match, $replace, trim($this->message)); @@ -994,7 +995,7 @@ class parse_message extends bbcode_firstpass if ($config['max_' . $mode . '_urls']) { - $num_urls += preg_match_all('#\' . $row['emotion'] . ''; } $db->sql_freeresult($result); @@ -1456,16 +1457,22 @@ class parse_message extends bbcode_firstpass $tmp_message = $this->message; $this->message = $poll['poll_title']; + $poll['poll_options'] = explode("\n", trim($poll['poll_option_text'])); + $poll['poll_options_size'] = sizeof($poll['poll_options']); - $poll['poll_title'] = $this->parse($poll['enable_bbcode'], ($config['allow_post_links']) ? $poll['enable_urls'] : false, $poll['enable_smilies'], $poll['img_status'], false, false, $config['allow_post_links'], false); + if (!$poll['poll_title'] && $poll['poll_options_size']) + { + $this->warn_msg[] = $user->lang['NO_POLL_TITLE']; + } + else + { + $poll['poll_title'] = $this->parse($poll['enable_bbcode'], ($config['allow_post_links']) ? $poll['enable_urls'] : false, $poll['enable_smilies'], $poll['img_status'], false, false, $config['allow_post_links'], false); + } $this->message = $tmp_message; unset($tmp_message); - $poll['poll_options'] = explode("\n", trim($poll['poll_option_text'])); - $poll['poll_options_size'] = sizeof($poll['poll_options']); - if (sizeof($poll['poll_options']) == 1) { $this->warn_msg[] = $user->lang['TOO_FEW_POLL_OPTIONS']; @@ -1479,11 +1486,6 @@ class parse_message extends bbcode_firstpass $this->warn_msg[] = $user->lang['TOO_MANY_USER_OPTIONS']; } - if (!$poll['poll_title'] && $poll['poll_options_size']) - { - $this->warn_msg[] = $user->lang['NO_POLL_TITLE']; - } - $poll['poll_max_options'] = ($poll['poll_max_options'] < 1) ? 1 : (($poll['poll_max_options'] > $config['max_poll_options']) ? $config['max_poll_options'] : $poll['poll_max_options']); } } -- cgit v1.2.1 From 6875bd59b4eb4bedd9b62855d2d9f571169690a4 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Tue, 12 Dec 2006 09:55:15 +0000 Subject: until nils comes to inspecting this further we will use this "workaround" git-svn-id: file:///svn/phpbb/trunk@6750 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/message_parser.php | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'phpBB/includes/message_parser.php') diff --git a/phpBB/includes/message_parser.php b/phpBB/includes/message_parser.php index 561b2d79da..ebac61dd8f 100644 --- a/phpBB/includes/message_parser.php +++ b/phpBB/includes/message_parser.php @@ -799,16 +799,23 @@ class bbcode_firstpass extends bbcode return ''; } - // Checking urls - if (preg_match('#' . preg_quote(generate_board_url(), '#') . '/([^ \t\n\r<"\']+)#i', $url) || - preg_match('#([\w]+?://.*?[^ \t\n\r<"\']*)#i', $url) || - preg_match('#(www\.[\w\-]+\.[\w\-.\~]+(?:/[^ \t\n\r<"\']*)?)#i', $url)) + // Before we check anything, we make sure certain characters are not included + if (!preg_match('#[\t\n\r<"\']#', $url)) { - $valid = true; + // Checking urls + if (preg_match('#' . preg_quote(generate_board_url(), '#') . '/([^ \t\n\r<"\']+)#i', $url) || + preg_match('#([\w]+?://.*?[^ \t\n\r<"\']*)#i', $url) || + preg_match('#(www\.[\w\-]+\.[\w\-.\~]+(?:/[^ \t\n\r<"\']*)?)#i', $url)) + { + $valid = true; + } } if ($valid) { + // Do we want to transform some characters? + $url = str_replace(' ', '%20', $url); + $this->parsed_items['url']++; if (!preg_match('#^[\w]+?://.*?#i', $url)) -- cgit v1.2.1 From 1e34820cd87837b545b310022ee460803d8c5b54 Mon Sep 17 00:00:00 2001 From: Nils Adermann Date: Sat, 16 Dec 2006 20:24:34 +0000 Subject: - Optimize acl_getf_global a bit - a little performance improvement of the IP regular expressions - convert post_text/subject collation to utf8_unicode_ci if a user wants to use mysql_fulltext to allow case insensitivity [Bug #6272] - mysql_fulltext should alter all necessary columns at once to speed up the process - validate URLs against RFC3986 - fixed some weirdness in make_clickable I hope I didn't break any URLs with this commit, if I did then report it to the bugtracker please! git-svn-id: file:///svn/phpbb/trunk@6774 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/message_parser.php | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'phpBB/includes/message_parser.php') diff --git a/phpBB/includes/message_parser.php b/phpBB/includes/message_parser.php index ebac61dd8f..a6687a94e5 100644 --- a/phpBB/includes/message_parser.php +++ b/phpBB/includes/message_parser.php @@ -783,6 +783,9 @@ class bbcode_firstpass extends bbcode /** * Validate url + * + * @param string $var1 optional url parameter for url bbcode: [url(=$var1)]$var2[/url] + * @param string $var2 url bbcode content: [url(=$var1)]$var2[/url] */ function validate_url($var1, $var2) { @@ -792,38 +795,35 @@ class bbcode_firstpass extends bbcode $var2 = str_replace("\r\n", "\n", str_replace('\"', '"', trim($var2))); $url = ($var1) ? $var1 : $var2; - $valid = false; if (!$url || ($var1 && !$var2)) { return ''; } - // Before we check anything, we make sure certain characters are not included - if (!preg_match('#[\t\n\r<"\']#', $url)) + $valid = false; + + $url = str_replace(' ', '%20', $url); + + // Checking urls + if (preg_match('#^' . get_preg_expression('url') . '$#i', $url) || + preg_match('#^' . get_preg_expression('www_url') . '$#i', $url) || + preg_match('#^' . preg_quote(generate_board_url(), '#') . get_preg_expression('relative_url') . '$#i', $url)) { - // Checking urls - if (preg_match('#' . preg_quote(generate_board_url(), '#') . '/([^ \t\n\r<"\']+)#i', $url) || - preg_match('#([\w]+?://.*?[^ \t\n\r<"\']*)#i', $url) || - preg_match('#(www\.[\w\-]+\.[\w\-.\~]+(?:/[^ \t\n\r<"\']*)?)#i', $url)) - { - $valid = true; - } + $valid = true; } if ($valid) { - // Do we want to transform some characters? - $url = str_replace(' ', '%20', $url); - $this->parsed_items['url']++; - if (!preg_match('#^[\w]+?://.*?#i', $url)) + // if there is no scheme, then add http schema + if (!preg_match('#^[a-z][a-z\d+\-.]*:/{2}#i', $url)) { $url = 'http://' . $url; } - // We take our test url and stick on the first bit of text we get to check if we are really at the domain. If so, lets go! + // Is this a link to somewhere inside this board? If so then remove the session id from the url if (strpos($url, generate_board_url()) !== false && strpos($url, 'sid=') !== false) { $url = preg_replace('/(&|\?)sid=[0-9a-f]{32}/', '\1', $url); -- cgit v1.2.1 From e84d85d88cc5a88854a50bf025d766726c030f2a Mon Sep 17 00:00:00 2001 From: David M Date: Sun, 17 Dec 2006 17:59:08 +0000 Subject: - Changed handling of the bitfield in bbcode.php - #6270, reverted to an earlier version of list handling + bug fixes git-svn-id: file:///svn/phpbb/trunk@6777 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/message_parser.php | 80 ++++++++++++++++++++++++++------------- 1 file changed, 54 insertions(+), 26 deletions(-) (limited to 'phpBB/includes/message_parser.php') diff --git a/phpBB/includes/message_parser.php b/phpBB/includes/message_parser.php index a6687a94e5..251e736a14 100644 --- a/phpBB/includes/message_parser.php +++ b/phpBB/includes/message_parser.php @@ -119,7 +119,7 @@ class bbcode_firstpass extends bbcode 'size' => array('bbcode_id' => 5, 'regexp' => array('#\[size=([\-\+]?[1-2]?[0-9])\](.*?)\[/size\]#ise' => "\$this->bbcode_size('\$1', '\$2')")), 'color' => array('bbcode_id' => 6, 'regexp' => array('!\[color=(#[0-9A-Fa-f]{6}|[a-z\-]+)\](.*?)\[/color\]!ise' => "\$this->bbcode_color('\$1', '\$2')")), 'u' => array('bbcode_id' => 7, 'regexp' => array('#\[u\](.*?)\[/u\]#ise' => "\$this->bbcode_underline('\$1')")), - 'list' => array('bbcode_id' => 9, 'regexp' => array('#\[list(=[a-z|0-9|(?:disc|circle|square))]+)?\].*\[/list\]#ise' => "\$this->bbcode_parse_list('\$0')")), + 'list' => array('bbcode_id' => 9, 'regexp' => array('#\[list(?:=(?:[a-z0-9]|disc|circle|square))?].*\[/list]#ise' => "\$this->bbcode_parse_list('\$0')")), 'email' => array('bbcode_id' => 10, 'regexp' => array('#\[email=?(.*?)?\](.*?)\[/email\]#ise' => "\$this->validate_email('\$1', '\$2')")), 'flash' => array('bbcode_id' => 11, 'regexp' => array('#\[flash=([0-9]+),([0-9]+)\](.*?)\[/flash\]#ie' => "\$this->bbcode_flash('\$1', '\$2', '\$3')")) ); @@ -484,27 +484,13 @@ class bbcode_firstpass extends bbcode return ''; } - $out = '['; - - // Grab item_start with no item_end - $in = preg_replace('#\[\*\](.*?)(\[\/list\]|\[list(=?(?:[0-9]|[a-z]|))\]|\[\*\])#is', '[*:' . $this->bbcode_uid . ']\1[/*:m:' . $this->bbcode_uid . ']\2', $in); - - // Grab them again as backreference - $in = preg_replace('#\[\*\](.*?)(\[\/list\]|\[list(=?(?:[0-9]|[a-z]|))\]|\[\*\])(^\[\/*\])#is', '[*:' . $this->bbcode_uid . ']\1[/*:m:' . $this->bbcode_uid . ']\2', $in); - - // Grab end tag following start tag - $in = preg_replace('#\[\/\*:m:' . $this->bbcode_uid . '\](\n|)\[\*\]#is', '[/*:m:' . $this->bbcode_uid . '][*:' . $this->bbcode_uid . ']', $in); - - // Replace end tag - $in = preg_replace('#\[\/\*\]#i', '[/*:' . $this->bbcode_uid . ']', $in); - // $tok holds characters to stop at. Since the string starts with a '[' we'll get everything up to the first ']' which should be the opening [list] tag $tok = ']'; $out = '['; // First character is [ $in = substr($in, 1); - $list_end_tags = array(); + $list_end_tags = $item_end_tags = array(); do { @@ -512,7 +498,7 @@ class bbcode_firstpass extends bbcode for ($i = 0, $tok_len = strlen($tok); $i < $tok_len; ++$i) { - $tmp_pos = strpos($in, $tok{$i}); + $tmp_pos = strpos($in, $tok[$i]); if ($tmp_pos !== false && $tmp_pos < $pos) { @@ -521,7 +507,7 @@ class bbcode_firstpass extends bbcode } $buffer = substr($in, 0, $pos); - $tok = $in{$pos}; + $tok = $in[$pos]; $in = substr($in, $pos + 1); @@ -530,13 +516,20 @@ class bbcode_firstpass extends bbcode // if $tok is ']' the buffer holds a tag if (strtolower($buffer) == '/list' && sizeof($list_end_tags)) { + // valid [/list] tag + if (sizeof($item_end_tags)) + { + // current li tag has not been closed + $out = preg_replace('/\n?\[$/', '[', $out) . array_pop($item_end_tags) . ']['; + } + $out .= array_pop($list_end_tags) . ']'; $tok = '['; } - else if (preg_match('#list(=?(?:[0-9]|[a-z]|))#i', $buffer, $m)) + else if (preg_match('#list(=[0-9a-z])?#i', $buffer, $m)) { // sub-list, add a closing tag - if (!$m[1] || preg_match('/^(disc|square|circle)$/i', $m[1])) + if (empty($m[1]) || preg_match('/^(disc|square|circle)$/i', $m[1])) { array_push($list_end_tags, '/list:u:' . $this->bbcode_uid); } @@ -544,17 +537,47 @@ class bbcode_firstpass extends bbcode { array_push($list_end_tags, '/list:o:' . $this->bbcode_uid); } - - if (strtolower(substr($buffer, 0, 4)) == 'list') - { - $buffer = 'list' . substr($buffer, 4, $pos); - } - $out .= $buffer . ':' . $this->bbcode_uid . ']'; $tok = '['; } else { + if (($buffer == '*' || substr($buffer, -2) == '[*') && sizeof($list_end_tags)) + { + // the buffer holds a bullet tag and we have a [list] tag open + if (sizeof($item_end_tags) >= sizeof($list_end_tags)) + { + if (substr($buffer, -2) == '[*') + { + $out .= substr($buffer, 0, -2) . '['; + } + // current li tag has not been closed + if (preg_match('/\n\[$/', $out, $m)) + { + $out = preg_replace('/\n\[$/', '[', $out); + $buffer = array_pop($item_end_tags) . "]\n[*:" . $this->bbcode_uid; + } + else + { + $buffer = array_pop($item_end_tags) . '][*:' . $this->bbcode_uid; + } + } + else + { + $buffer = '*:' . $this->bbcode_uid; + } + + $item_end_tags[] = '/*:m:' . $this->bbcode_uid; + } + else if ($buffer == '/*') + { + if (array_pop($item_end_tags) == '/*:m:' . $this->bbcode_uid) + { + array_pop($item_end_tags); + } + $buffer = '/*:' . $this->bbcode_uid; + } + $out .= $buffer . $tok; $tok = '[]'; } @@ -568,6 +591,11 @@ class bbcode_firstpass extends bbcode } while ($in); + // do we have some tags open? close them now + if (sizeof($item_end_tags)) + { + $out .= '[' . implode('][', $item_end_tags) . ']'; + } if (sizeof($list_end_tags)) { $out .= '[' . implode('][', $list_end_tags) . ']'; -- cgit v1.2.1 From ae1cb0316e6c19d62f0579e9cef52f11df081bcf Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Sun, 24 Dec 2006 13:11:54 +0000 Subject: some fixes today - most important change is the consolidation of the display attachment functions; merging them together to have one function we need to call. git-svn-id: file:///svn/phpbb/trunk@6803 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/message_parser.php | 100 +++++++++++++++++++------------------- 1 file changed, 51 insertions(+), 49 deletions(-) (limited to 'phpBB/includes/message_parser.php') diff --git a/phpBB/includes/message_parser.php b/phpBB/includes/message_parser.php index 251e736a14..c139af5ef7 100644 --- a/phpBB/includes/message_parser.php +++ b/phpBB/includes/message_parser.php @@ -1213,7 +1213,22 @@ class parse_message extends bbcode_firstpass $add_file = (isset($_POST['add_file'])) ? true : false; $delete_file = (isset($_POST['delete_file'])) ? true : false; - $edit_comment = (isset($_POST['edit_comment'])) ? true : false; + + // First of all adjust comments if changed + $actual_comment_list = utf8_normalize_nfc(request_var('comment_list', array(''), true)); + + foreach ($actual_comment_list as $comment_key => $comment) + { + if (!isset($this->attachment_data[$comment_key])) + { + continue; + } + + if ($this->attachment_data[$comment_key]['attach_comment'] != $actual_comment_list[$comment_key]) + { + $this->attachment_data[$comment_key]['attach_comment'] = $actual_comment_list[$comment_key]; + } + } $cfg = array(); $cfg['max_attachments'] = ($is_message) ? $config['max_attachments_pm'] : $config['max_attachments']; @@ -1284,7 +1299,6 @@ class parse_message extends bbcode_firstpass if (!empty($this->attachment_data[$index])) { - // delete selected attachment if ($this->attachment_data[$index]['is_orphan']) { @@ -1321,59 +1335,47 @@ class parse_message extends bbcode_firstpass $this->attachment_data = array_values($this->attachment_data); } } - else if ($edit_comment || $add_file || $preview) + else if (($add_file || $preview) && $upload_file) { - if ($edit_comment) - { - $actual_comment_list = utf8_normalize_nfc(request_var('comment_list', array(''), true)); - - $edit_comment = request_var('edit_comment', array(0 => '')); - $edit_comment = key($edit_comment); - $this->attachment_data[$edit_comment]['attach_comment'] = $actual_comment_list[$edit_comment]; - } - - if (($add_file || $preview) && $upload_file) + if ($num_attachments < $cfg['max_attachments'] || $auth->acl_gets('m_', 'a_', $forum_id)) { - if ($num_attachments < $cfg['max_attachments'] || $auth->acl_gets('m_', 'a_', $forum_id)) - { - $filedata = upload_attachment($form_name, $forum_id, false, '', $is_message); - $error = array_merge($error, $filedata['error']); + $filedata = upload_attachment($form_name, $forum_id, false, '', $is_message); + $error = array_merge($error, $filedata['error']); - if (!sizeof($error)) - { - $sql_ary = array( - 'physical_filename' => $filedata['physical_filename'], - 'attach_comment' => $this->filename_data['filecomment'], - 'real_filename' => $filedata['real_filename'], - 'extension' => $filedata['extension'], - 'mimetype' => $filedata['mimetype'], - 'filesize' => $filedata['filesize'], - 'filetime' => $filedata['filetime'], - 'thumbnail' => $filedata['thumbnail'], - 'is_orphan' => 1, - 'in_message' => ($is_message) ? 1 : 0, - 'poster_id' => $user->data['user_id'], - ); - - $db->sql_query('INSERT INTO ' . ATTACHMENTS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary)); - - $new_entry = array( - 'attach_id' => $db->sql_nextid(), - 'is_orphan' => 1, - 'real_filename' => $filedata['real_filename'], - 'attach_comment'=> $this->filename_data['filecomment'], - ); - - $this->attachment_data = array_merge(array(0 => $new_entry), $this->attachment_data); - $this->message = preg_replace('#\[attachment=([0-9]+)\](.*?)\[\/attachment\]#e', "'[attachment='.(\\1 + 1).']\\2[/attachment]'", $this->message); - $this->filename_data['filecomment'] = ''; - } - } - else + if (!sizeof($error)) { - $error[] = sprintf($user->lang['TOO_MANY_ATTACHMENTS'], $cfg['max_attachments']); + $sql_ary = array( + 'physical_filename' => $filedata['physical_filename'], + 'attach_comment' => $this->filename_data['filecomment'], + 'real_filename' => $filedata['real_filename'], + 'extension' => $filedata['extension'], + 'mimetype' => $filedata['mimetype'], + 'filesize' => $filedata['filesize'], + 'filetime' => $filedata['filetime'], + 'thumbnail' => $filedata['thumbnail'], + 'is_orphan' => 1, + 'in_message' => ($is_message) ? 1 : 0, + 'poster_id' => $user->data['user_id'], + ); + + $db->sql_query('INSERT INTO ' . ATTACHMENTS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary)); + + $new_entry = array( + 'attach_id' => $db->sql_nextid(), + 'is_orphan' => 1, + 'real_filename' => $filedata['real_filename'], + 'attach_comment'=> $this->filename_data['filecomment'], + ); + + $this->attachment_data = array_merge(array(0 => $new_entry), $this->attachment_data); + $this->message = preg_replace('#\[attachment=([0-9]+)\](.*?)\[\/attachment\]#e', "'[attachment='.(\\1 + 1).']\\2[/attachment]'", $this->message); + $this->filename_data['filecomment'] = ''; } } + else + { + $error[] = sprintf($user->lang['TOO_MANY_ATTACHMENTS'], $cfg['max_attachments']); + } } } -- cgit v1.2.1 From f0129b6f27cc05f9e6488729acd32739e2616602 Mon Sep 17 00:00:00 2001 From: David M Date: Sun, 24 Dec 2006 14:28:01 +0000 Subject: #6542 git-svn-id: file:///svn/phpbb/trunk@6804 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/message_parser.php | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'phpBB/includes/message_parser.php') diff --git a/phpBB/includes/message_parser.php b/phpBB/includes/message_parser.php index c139af5ef7..69b085e516 100644 --- a/phpBB/includes/message_parser.php +++ b/phpBB/includes/message_parser.php @@ -84,15 +84,12 @@ class bbcode_firstpass extends bbcode function prepare_bbcodes() { // Add newline at the end and in front of each quote block to prevent parsing errors (urls, smilies, etc.) - if (strpos($this->message, '[quote') !== false) + if (strpos($this->message, '[quote') !== false && strpos($this->message, '[/quote]') !== false) { $this->message = str_replace("\r\n", "\n", $this->message); - // We strip newlines and spaces after and before quotes in quotes (trimming) - $this->message = preg_replace(array('#\[quote(=".*?")?\]([\s|\n]+)#ius', '#([\s|\n]+)\[\/quote\]#ius'), array("[quote\\1]", "[/quote]"), $this->message); - - // Now we add exactly one newline - $this->message = preg_replace(array('#\[quote(=".*?")?\]#is', '#\[\/quote\]#is'), array("[quote\\1]\n", "\n[/quote]"), $this->message); + // We strip newlines and spaces after and before quotes in quotes (trimming) and then add exactly one newline + $this->message = preg_replace('#\[quote(=".*?")?\]\s*(.*?)\s*\[/quote\]#siu', '[quote\1]' . "\n" . '\2' ."\n[/quote]", $this->message); } // Add other checks which needs to be placed before actually parsing anything (be it bbcodes, smilies, urls...) -- cgit v1.2.1 From cbd1fb07ed9e0a19e19a58098e1b00bb74a102d5 Mon Sep 17 00:00:00 2001 From: David M Date: Sun, 24 Dec 2006 14:34:26 +0000 Subject: sprintf git-svn-id: file:///svn/phpbb/trunk@6805 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/message_parser.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes/message_parser.php') diff --git a/phpBB/includes/message_parser.php b/phpBB/includes/message_parser.php index 69b085e516..9751ab676e 100644 --- a/phpBB/includes/message_parser.php +++ b/phpBB/includes/message_parser.php @@ -55,7 +55,7 @@ class bbcode_firstpass extends bbcode { if (preg_match($regexp, $this->message)) { - $this->warn_msg[] = $user->lang['UNAUTHORISED_BBCODE'] . '[' . $bbcode_name . ']'; + $this->warn_msg[] = sprintf($user->lang['UNAUTHORISED_BBCODE'] , '[' . $bbcode_name . ']'); continue; } } -- cgit v1.2.1 From 677dc5d2e11c3209fcaf798e4b44588a9305328f Mon Sep 17 00:00:00 2001 From: David M Date: Tue, 26 Dec 2006 20:49:20 +0000 Subject: #6598 - should have fixed all uses of curly braces git-svn-id: file:///svn/phpbb/trunk@6813 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/message_parser.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes/message_parser.php') diff --git a/phpBB/includes/message_parser.php b/phpBB/includes/message_parser.php index 9751ab676e..07ba6c5b00 100644 --- a/phpBB/includes/message_parser.php +++ b/phpBB/includes/message_parser.php @@ -445,7 +445,7 @@ class bbcode_firstpass extends bbcode $code = preg_replace('#(?:[\n\r\s\t]| )*$#u', '', $code); // remove newline at the end - if (!empty($code) && $code{strlen($code)-1} == "\n") + if (!empty($code) && $code[strlen($code) - 1] == "\n") { $code = substr($code, 0, -1); } -- cgit v1.2.1 From 2b35b9d60d42c750485ba84b31818fad0b4e0a91 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Tue, 9 Jan 2007 14:10:44 +0000 Subject: - some bugfixes - bugfixes for the convertor (typecasting for example was totally broken) git-svn-id: file:///svn/phpbb/trunk@6865 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/message_parser.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes/message_parser.php') diff --git a/phpBB/includes/message_parser.php b/phpBB/includes/message_parser.php index 07ba6c5b00..138c7f48bf 100644 --- a/phpBB/includes/message_parser.php +++ b/phpBB/includes/message_parser.php @@ -114,7 +114,7 @@ class bbcode_firstpass extends bbcode 'url' => array('bbcode_id' => 3, 'regexp' => array('#\[url(=(.*))?\](.*)\[/url\]#iUe' => "\$this->validate_url('\$2', '\$3')")), 'img' => array('bbcode_id' => 4, 'regexp' => array('#\[img\](https?://)([a-z0-9\-\.,\?!%\*_:;~\\&$@/=\+]+)\[/img\]#ie' => "\$this->bbcode_img('\$1\$2')")), 'size' => array('bbcode_id' => 5, 'regexp' => array('#\[size=([\-\+]?[1-2]?[0-9])\](.*?)\[/size\]#ise' => "\$this->bbcode_size('\$1', '\$2')")), - 'color' => array('bbcode_id' => 6, 'regexp' => array('!\[color=(#[0-9A-Fa-f]{6}|[a-z\-]+)\](.*?)\[/color\]!ise' => "\$this->bbcode_color('\$1', '\$2')")), + 'color' => array('bbcode_id' => 6, 'regexp' => array('!\[color=(#[0-9a-f]{6}|[a-z\-]+)\](.*?)\[/color\]!ise' => "\$this->bbcode_color('\$1', '\$2')")), 'u' => array('bbcode_id' => 7, 'regexp' => array('#\[u\](.*?)\[/u\]#ise' => "\$this->bbcode_underline('\$1')")), 'list' => array('bbcode_id' => 9, 'regexp' => array('#\[list(?:=(?:[a-z0-9]|disc|circle|square))?].*\[/list]#ise' => "\$this->bbcode_parse_list('\$0')")), 'email' => array('bbcode_id' => 10, 'regexp' => array('#\[email=?(.*?)?\](.*?)\[/email\]#ise' => "\$this->validate_email('\$1', '\$2')")), -- cgit v1.2.1 From de07a9e0adf179a6ed17a1f919571c3f613a94f7 Mon Sep 17 00:00:00 2001 From: David M Date: Thu, 18 Jan 2007 04:25:11 +0000 Subject: #7228 git-svn-id: file:///svn/phpbb/trunk@6897 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/message_parser.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'phpBB/includes/message_parser.php') diff --git a/phpBB/includes/message_parser.php b/phpBB/includes/message_parser.php index 138c7f48bf..ab0ee59943 100644 --- a/phpBB/includes/message_parser.php +++ b/phpBB/includes/message_parser.php @@ -523,10 +523,10 @@ class bbcode_firstpass extends bbcode $out .= array_pop($list_end_tags) . ']'; $tok = '['; } - else if (preg_match('#list(=[0-9a-z])?#i', $buffer, $m)) + else if (preg_match('#^list(=[0-9a-z])?$#i', $buffer, $m)) { // sub-list, add a closing tag - if (empty($m[1]) || preg_match('/^(disc|square|circle)$/i', $m[1])) + if (empty($m[1]) || preg_match('/^(?:disc|square|circle)$/i', $m[1])) { array_push($list_end_tags, '/list:u:' . $this->bbcode_uid); } -- cgit v1.2.1 From a64caea9b627cb6fd4b5f9123d3479c08b4328c4 Mon Sep 17 00:00:00 2001 From: David M Date: Thu, 18 Jan 2007 05:09:35 +0000 Subject: - found a small bug in the list parser while working on another bug git-svn-id: file:///svn/phpbb/trunk@6898 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/message_parser.php | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) (limited to 'phpBB/includes/message_parser.php') diff --git a/phpBB/includes/message_parser.php b/phpBB/includes/message_parser.php index ab0ee59943..e5e2240b6d 100644 --- a/phpBB/includes/message_parser.php +++ b/phpBB/includes/message_parser.php @@ -513,8 +513,8 @@ class bbcode_firstpass extends bbcode // if $tok is ']' the buffer holds a tag if (strtolower($buffer) == '/list' && sizeof($list_end_tags)) { - // valid [/list] tag - if (sizeof($item_end_tags)) + // valid [/list] tag, check nesting so that we don't hit false positives + if (sizeof($item_end_tags) && sizeof($item_end_tags) >= sizeof($list_end_tags)) { // current li tag has not been closed $out = preg_replace('/\n?\[$/', '[', $out) . array_pop($item_end_tags) . ']['; @@ -568,10 +568,7 @@ class bbcode_firstpass extends bbcode } else if ($buffer == '/*') { - if (array_pop($item_end_tags) == '/*:m:' . $this->bbcode_uid) - { - array_pop($item_end_tags); - } + array_pop($item_end_tags); $buffer = '/*:' . $this->bbcode_uid; } @@ -1182,16 +1179,26 @@ class parse_message extends bbcode_firstpass { if ($max_smilies) { - $num_matches = preg_match_all('#' . str_replace('#', '', implode('|', $match)) . '#', $this->message, $matches); - unset($matches); - - if ($num_matches !== false && $num_matches > $max_smilies) + $count = 0; + foreach ($match as $key => $smilie) { - $this->warn_msg[] = sprintf($user->lang['TOO_MANY_SMILIES'], $max_smilies); - return; + if ($small_count = preg_match_all($smilie, $this->message, $array)) + { + $count += $small_count; + if ($count > $max_smilies) + { + $this->warn_msg[] = sprintf($user->lang['TOO_MANY_SMILIES'], $max_smilies); + return; + } + } + $this->message = preg_replace($smilie, $replace[$key], $this->message); } + $this->message = trim($this->message); + } + else + { + $this->message = trim(preg_replace($match, $replace, $this->message)); } - $this->message = trim(preg_replace($match, $replace, $this->message)); } } -- cgit v1.2.1