aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--phpBB/includes/acp/acp_styles.php27
-rw-r--r--phpBB/includes/functions_content.php10
-rw-r--r--phpBB/includes/mcp/mcp_logs.php2
-rw-r--r--phpBB/includes/message_parser.php12
-rw-r--r--phpBB/index.php2
-rw-r--r--phpBB/language/en/acp/styles.php1
-rw-r--r--phpBB/language/en/memberlist.php2
-rw-r--r--phpBB/phpbb/auth/provider/db.php2
-rw-r--r--phpBB/phpbb/avatar/manager.php40
-rw-r--r--phpBB/phpbb/message/topic_form.php2
-rw-r--r--phpBB/posting.php2
-rw-r--r--phpBB/styles/prosilver/template/forumlist_body.html2
-rw-r--r--phpBB/styles/prosilver/template/memberlist_email.html2
-rw-r--r--phpBB/styles/subsilver2/template/memberlist_email.html4
-rw-r--r--tests/avatar/fixtures/users.xml28
-rw-r--r--tests/avatar/manager_test.php56
-rw-r--r--tests/functions/make_clickable_test.php100
17 files changed, 253 insertions, 41 deletions
diff --git a/phpBB/includes/acp/acp_styles.php b/phpBB/includes/acp/acp_styles.php
index af3fd7937c..6bd27a8bca 100644
--- a/phpBB/includes/acp/acp_styles.php
+++ b/phpBB/includes/acp/acp_styles.php
@@ -29,14 +29,31 @@ class acp_styles
protected $styles_path;
protected $styles_path_absolute = 'styles';
protected $default_style = 0;
+ protected $styles_list_cols = 0;
+ protected $reserved_style_names = array('adm', 'admin', 'all');
+ /** @var \phpbb\db\driver\driver_interface */
protected $db;
+
+ /** @var \phpbb\user */
protected $user;
+
+ /** @var \phpbb\template\template */
protected $template;
+
+ /** @var \phpbb\request\request_interface */
protected $request;
+
+ /** @var \phpbb\cache\driver\driver_interface */
protected $cache;
+
+ /** @var \phpbb\auth\auth */
protected $auth;
+
+ /** @var string */
protected $phpbb_root_path;
+
+ /** @var string */
protected $php_ext;
public function main($id, $mode)
@@ -164,6 +181,12 @@ class acp_styles
$last_installed = false;
foreach ($dirs as $dir)
{
+ if (in_array($dir, $this->reserved_style_names))
+ {
+ $messages[] = $this->user->lang('STYLE_NAME_RESERVED', htmlspecialchars($dir));
+ continue;
+ }
+
$found = false;
foreach ($styles as &$style)
{
@@ -809,7 +832,7 @@ class acp_styles
* Update styles tree
*
* @param array $styles Styles list, passed as reference
- * @param array $style Current style, false if root
+ * @param array|false $style Current style, false if root
* @return bool True if something was updated, false if not
*/
protected function update_styles_tree(&$styles, $style = false)
@@ -1091,7 +1114,7 @@ class acp_styles
/**
* Install style
*
- * @param $style style data
+ * @param array $style style data
* @return int Style id
*/
protected function install_style($style)
diff --git a/phpBB/includes/functions_content.php b/phpBB/includes/functions_content.php
index 25ca50e8f1..87cf34bd9d 100644
--- a/phpBB/includes/functions_content.php
+++ b/phpBB/includes/functions_content.php
@@ -712,7 +712,7 @@ function make_clickable_callback($type, $whitespace, $url, $relative_url, $class
break;
}
- $short_url = (strlen($url) > 55) ? substr($url, 0, 39) . ' ... ' . substr($url, -10) : $url;
+ $short_url = (utf8_strlen($url) > 55) ? utf8_substr($url, 0, 39) . ' ... ' . utf8_substr($url, -10) : $url;
switch ($type)
{
@@ -788,28 +788,28 @@ function make_clickable($text, $server_url = false, $class = 'postlink')
// relative urls for this board
$magic_url_match_args[$server_url][] = array(
- '#(^|[\n\t (>.])(' . preg_quote($server_url, '#') . ')/(' . get_preg_expression('relative_url_inline') . ')#i',
+ '#(^|[\n\t (>.])(' . preg_quote($server_url, '#') . ')/(' . get_preg_expression('relative_url_inline') . ')#iu',
MAGIC_URL_LOCAL,
$local_class,
);
// matches a xxxx://aaaaa.bbb.cccc. ...
$magic_url_match_args[$server_url][] = array(
- '#(^|[\n\t (>.])(' . get_preg_expression('url_inline') . ')#i',
+ '#(^|[\n\t (>.])(' . get_preg_expression('url_inline') . ')#iu',
MAGIC_URL_FULL,
$class,
);
// matches a "www.xxxx.yyyy[/zzzz]" kinda lazy URL thing
$magic_url_match_args[$server_url][] = array(
- '#(^|[\n\t (>])(' . get_preg_expression('www_url_inline') . ')#i',
+ '#(^|[\n\t (>])(' . get_preg_expression('www_url_inline') . ')#iu',
MAGIC_URL_WWW,
$class,
);
// matches an email@domain type address at the start of a line, or after a space or after what might be a BBCode.
$magic_url_match_args[$server_url][] = array(
- '/(^|[\n\t (>])(' . get_preg_expression('email') . ')/i',
+ '/(^|[\n\t (>])(' . get_preg_expression('email') . ')/iu',
MAGIC_URL_EMAIL,
'',
);
diff --git a/phpBB/includes/mcp/mcp_logs.php b/phpBB/includes/mcp/mcp_logs.php
index 92dcdb5499..9c76f0df90 100644
--- a/phpBB/includes/mcp/mcp_logs.php
+++ b/phpBB/includes/mcp/mcp_logs.php
@@ -137,7 +137,7 @@ class mcp_logs
if ($mode == 'topic_logs')
{
- $conditions['topic_logs'] = $topic_id;
+ $conditions['topic_id'] = $topic_id;
}
$phpbb_log->delete('mod', $conditions);
diff --git a/phpBB/includes/message_parser.php b/phpBB/includes/message_parser.php
index bc996cf275..12ef94c07a 100644
--- a/phpBB/includes/message_parser.php
+++ b/phpBB/includes/message_parser.php
@@ -313,7 +313,7 @@ class bbcode_firstpass extends bbcode
$in = str_replace(' ', '%20', $in);
// Checking urls
- if (!preg_match('#^' . get_preg_expression('url') . '$#i', $in) && !preg_match('#^' . get_preg_expression('www_url') . '$#i', $in))
+ if (!preg_match('#^' . get_preg_expression('url') . '$#i', $in) && !preg_match('#^' . get_preg_expression('www_url') . '$#iu', $in))
{
return '[img]' . $in . '[/img]';
}
@@ -381,8 +381,8 @@ class bbcode_firstpass extends bbcode
$in = str_replace(' ', '%20', $in);
// Make sure $in is a URL.
- if (!preg_match('#^' . get_preg_expression('url') . '$#i', $in) &&
- !preg_match('#^' . get_preg_expression('www_url') . '$#i', $in))
+ if (!preg_match('#^' . get_preg_expression('url') . '$#iu', $in) &&
+ !preg_match('#^' . get_preg_expression('www_url') . '$#iu', $in))
{
return '[flash=' . $width . ',' . $height . ']' . $in . '[/flash]';
}
@@ -973,9 +973,9 @@ class bbcode_firstpass extends bbcode
$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))
+ if (preg_match('#^' . get_preg_expression('url') . '$#iu', $url) ||
+ preg_match('#^' . get_preg_expression('www_url') . '$#iu', $url) ||
+ preg_match('#^' . preg_quote(generate_board_url(), '#') . get_preg_expression('relative_url') . '$#iu', $url))
{
$valid = true;
}
diff --git a/phpBB/index.php b/phpBB/index.php
index a36d74e0e9..df6932f6c0 100644
--- a/phpBB/index.php
+++ b/phpBB/index.php
@@ -185,7 +185,7 @@ $template->assign_vars(array(
'U_MCP' => ($auth->acl_get('m_') || $auth->acl_getf_global('m_')) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=main&mode=front', true, $user->session_id) : '')
);
-$page_title = $user->lang['INDEX'];
+$page_title = ($config['board_index_text'] !== '') ? $config['board_index_text'] : $user->lang['INDEX'];
/**
* You can use this event to modify the page title and load data for the index
diff --git a/phpBB/language/en/acp/styles.php b/phpBB/language/en/acp/styles.php
index 506d569d56..e6b05c8282 100644
--- a/phpBB/language/en/acp/styles.php
+++ b/phpBB/language/en/acp/styles.php
@@ -74,6 +74,7 @@ $lang = array_merge($lang, array(
'STYLE_INSTALLED_RETURN_INSTALLED_STYLES' => 'Return to installed styles list',
'STYLE_INSTALLED_RETURN_UNINSTALLED_STYLES' => 'Install more styles',
'STYLE_NAME' => 'Style name',
+ 'STYLE_NAME_RESERVED' => 'Style "%s" can not be installed, because the name is reserved.',
'STYLE_NOT_INSTALLED' => 'Style "%s" was not installed.',
'STYLE_PATH' => 'Style path',
'STYLE_UNINSTALL' => 'Uninstall',
diff --git a/phpBB/language/en/memberlist.php b/phpBB/language/en/memberlist.php
index b8c626d331..5605f8f4b5 100644
--- a/phpBB/language/en/memberlist.php
+++ b/phpBB/language/en/memberlist.php
@@ -48,7 +48,7 @@ $lang = array_merge($lang, array(
'BEFORE' => 'Before',
- 'CC_EMAIL' => 'Send a copy of this email to yourself.',
+ 'CC_SENDER' => 'Send a copy of this email to yourself.',
'CONTACT_ADMIN' => 'Contact a Board Administrator',
'DEST_LANG' => 'Language',
diff --git a/phpBB/phpbb/auth/provider/db.php b/phpBB/phpbb/auth/provider/db.php
index ba67c11e75..d8c5fb72de 100644
--- a/phpBB/phpbb/auth/provider/db.php
+++ b/phpBB/phpbb/auth/provider/db.php
@@ -232,7 +232,7 @@ class db extends \phpbb\auth\provider\base
// Give status about wrong password...
return array(
'status' => ($show_captcha) ? LOGIN_ERROR_ATTEMPTS : LOGIN_ERROR_PASSWORD,
- 'error_msg' => ($show_captcha) ? 'LOGIN_ERROR_ATTEMPTS' : 'LOGIN_ERROR_PASSWORD',
+ 'error_msg' => 'LOGIN_ERROR_PASSWORD',
'user_row' => $row,
);
}
diff --git a/phpBB/phpbb/avatar/manager.php b/phpBB/phpbb/avatar/manager.php
index 42ae61a9a2..8d83152ed6 100644
--- a/phpBB/phpbb/avatar/manager.php
+++ b/phpBB/phpbb/avatar/manager.php
@@ -326,17 +326,41 @@ class manager
$driver->delete($avatar_data);
}
- $result = self::$default_row;
+ $result = $this->prefix_avatar_columns($prefix, self::$default_row);
- foreach ($result as $key => $value)
+ $sql = 'UPDATE ' . $table . '
+ SET ' . $db->sql_build_array('UPDATE', $result) . '
+ WHERE ' . $prefix . 'id = ' . (int) $avatar_data['id'];
+ $db->sql_query($sql);
+
+ // Make sure we also delete this avatar from the users
+ if ($prefix === 'group_')
{
- $result[$prefix . $key] = $value;
- unset($result[$key]);
+ $result = $this->prefix_avatar_columns('user_', self::$default_row);
+
+ $sql = 'UPDATE ' . USERS_TABLE . '
+ SET ' . $db->sql_build_array('UPDATE', $result) . "
+ WHERE user_avatar = '" . $db->sql_escape($avatar_data['avatar']) . "'";
+ $db->sql_query($sql);
}
+ }
- $sql = 'UPDATE ' . $table . '
- SET ' . $db->sql_build_array('UPDATE', $result) . '
- WHERE ' . $prefix . 'id = ' . (int) $avatar_data['id'];
- $db->sql_query($sql);
+ /**
+ * Prefix avatar columns
+ *
+ * @param string $prefix Column prefix
+ * @param array $data Column data
+ *
+ * @return array Column data with prefixed column names
+ */
+ public function prefix_avatar_columns($prefix, $data)
+ {
+ foreach ($data as $key => $value)
+ {
+ $data[$prefix . $key] = $value;
+ unset($data[$key]);
+ }
+
+ return $data;
}
}
diff --git a/phpBB/phpbb/message/topic_form.php b/phpBB/phpbb/message/topic_form.php
index 1e0f2a1945..174643bb81 100644
--- a/phpBB/phpbb/message/topic_form.php
+++ b/phpBB/phpbb/message/topic_form.php
@@ -117,7 +117,7 @@ class topic_form extends form
'TOPIC_NAME' => htmlspecialchars_decode($this->topic_row['topic_title']),
'U_TOPIC' => generate_board_url() . '/viewtopic.' . $this->phpEx . '?f=' . $this->topic_row['forum_id'] . '&t=' . $this->topic_id,
));
-
+ $this->message->set_body($this->body);
$this->message->add_recipient(
$this->recipient_name,
$this->recipient_address,
diff --git a/phpBB/posting.php b/phpBB/posting.php
index 4c32276d17..dda7455845 100644
--- a/phpBB/posting.php
+++ b/phpBB/posting.php
@@ -1161,7 +1161,7 @@ if ($submit || $preview || $refresh)
break;
}
- if (!$auth->acl_get($auth_option, $forum_id))
+ if ($auth_option != '' && !$auth->acl_get($auth_option, $forum_id))
{
// There is a special case where a user edits his post whereby the topic type got changed by an admin/mod.
// Another case would be a mod not having sticky permissions for example but edit permissions.
diff --git a/phpBB/styles/prosilver/template/forumlist_body.html b/phpBB/styles/prosilver/template/forumlist_body.html
index c90f5b0639..3e7a2cd102 100644
--- a/phpBB/styles/prosilver/template/forumlist_body.html
+++ b/phpBB/styles/prosilver/template/forumlist_body.html
@@ -80,6 +80,8 @@
{L_POST_BY_AUTHOR} {forumrow.LAST_POSTER_FULL}
<!-- IF not S_IS_BOT --><a href="{forumrow.U_LAST_POST}">{LAST_POST_IMG}</a> <!-- ENDIF --><br />{forumrow.LAST_POST_TIME}<!-- ELSE -->{L_NO_POSTS}<br />&nbsp;<!-- ENDIF --></span>
</dd>
+ <!-- ELSE -->
+ <dd>&nbsp;</dd>
<!-- ENDIF -->
</dl>
<!-- EVENT forumlist_body_forum_row_append -->
diff --git a/phpBB/styles/prosilver/template/memberlist_email.html b/phpBB/styles/prosilver/template/memberlist_email.html
index e848844093..1bfd83e3a1 100644
--- a/phpBB/styles/prosilver/template/memberlist_email.html
+++ b/phpBB/styles/prosilver/template/memberlist_email.html
@@ -80,7 +80,7 @@
<!-- IF S_REGISTERED_USER -->
<dl>
<dt>&nbsp;</dt>
- <dd><label for="cc_email"><input type="checkbox" name="cc_email" id="cc_email" value="1" checked="checked" tabindex="5" /> {L_CC_EMAIL}</label></dd>
+ <dd><label for="cc_sender"><input type="checkbox" name="cc_sender" id="cc_sender" value="1" checked="checked" tabindex="5" /> {L_CC_SENDER}</label></dd>
</dl>
<!-- ENDIF -->
</fieldset>
diff --git a/phpBB/styles/subsilver2/template/memberlist_email.html b/phpBB/styles/subsilver2/template/memberlist_email.html
index b52513c241..1416aa0c10 100644
--- a/phpBB/styles/subsilver2/template/memberlist_email.html
+++ b/phpBB/styles/subsilver2/template/memberlist_email.html
@@ -72,8 +72,8 @@
<td class="row2">
<table cellspacing="0" cellpadding="1" border="0">
<tr>
- <td><input type="checkbox" class="radio" name="cc_email" value="1" checked="checked" /></td>
- <td class="gen">{L_CC_EMAIL}</td>
+ <td><input type="checkbox" class="radio" name="cc_sender" value="1" checked="checked" /></td>
+ <td class="gen">{L_CC_SENDER}</td>
</tr>
</table>
</td>
diff --git a/tests/avatar/fixtures/users.xml b/tests/avatar/fixtures/users.xml
index 3e6586e909..1773d438c2 100644
--- a/tests/avatar/fixtures/users.xml
+++ b/tests/avatar/fixtures/users.xml
@@ -29,5 +29,33 @@
<value></value>
<value></value>
</row>
+ <row>
+ <value>3</value>
+ <value>foo</value>
+ <value></value>
+ <value></value>
+ <value>g5_1414350991.jpg</value>
+ <value>avatar.driver.upload</value>
+ <value>80</value>
+ <value>80</value>
+ </row>
+ </table>
+ <table name="phpbb_groups">
+ <column>group_id</column>
+ <column>group_type</column>
+ <column>group_name</column>
+ <column>group_avatar</column>
+ <column>group_avatar_type</column>
+ <column>group_avatar_width</column>
+ <column>group_avatar_height</column>
+ <row>
+ <value>5</value>
+ <value>3</value>
+ <value>ADMINISTRATORS</value>
+ <value>g5_1414350991.jpg</value>
+ <value>avatar.driver.upload</value>
+ <value>80</value>
+ <value>80</value>
+ </row>
</table>
</dataset>
diff --git a/tests/avatar/manager_test.php b/tests/avatar/manager_test.php
index 81c153aed4..a109a7b5de 100644
--- a/tests/avatar/manager_test.php
+++ b/tests/avatar/manager_test.php
@@ -299,17 +299,32 @@ class phpbb_avatar_manager_test extends \phpbb_database_test_case
public function data_handle_avatar_delete()
{
return array(
- array(array(
- 'avatar' => '',
- 'avatar_type' => '',
- 'avatar_width' => 0,
- 'avatar_height' => 0,
- ), 1, array(
- 'avatar' => 'foobar@example.com',
- 'avatar_type' => 'avatar.driver.gravatar',
- 'avatar_width' => '16',
- 'avatar_height' => '16',
- ), USERS_TABLE, 'user_'),
+ array(
+ array(
+ 'avatar' => '',
+ 'avatar_type' => '',
+ 'avatar_width' => 0,
+ 'avatar_height' => 0,
+ ), 1, array(
+ 'avatar' => 'foobar@example.com',
+ 'avatar_type' => 'avatar.driver.gravatar',
+ 'avatar_width' => '16',
+ 'avatar_height' => '16',
+ ), USERS_TABLE, 'user_',
+ ),
+ array(
+ array(
+ 'avatar' => '',
+ 'avatar_type' => '',
+ 'avatar_width' => 0,
+ 'avatar_height' => 0,
+ ), 5, array(
+ 'avatar' => 'g5_1414350991.jpg',
+ 'avatar_type' => 'avatar.driver.upload',
+ 'avatar_width' => '80',
+ 'avatar_height' => '80'
+ ), GROUPS_TABLE, 'group_',
+ ),
);
}
@@ -333,4 +348,23 @@ class phpbb_avatar_manager_test extends \phpbb_database_test_case
$this->assertEquals($value, $row[$key]);
}
}
+
+ /**
+ * @dependsOn test_handle_avatar_delete
+ */
+ public function test_user_group_avatar_deleted()
+ {
+ $sql = 'SELECT * FROM ' . USERS_TABLE . '
+ WHERE user_id = 3';
+ $result = $this->db->sql_query_limit($sql, 1);
+ $row = $this->manager->clean_row($this->db->sql_fetchrow($result), 'user');
+ $this->db->sql_freeresult($result);
+
+ $this->assertEquals(array(
+ 'avatar' => '',
+ 'avatar_type' => '',
+ 'avatar_width' => 0,
+ 'avatar_height' => 0,
+ ), $row);
+ }
}
diff --git a/tests/functions/make_clickable_test.php b/tests/functions/make_clickable_test.php
new file mode 100644
index 0000000000..e61cb2c30e
--- /dev/null
+++ b/tests/functions/make_clickable_test.php
@@ -0,0 +1,100 @@
+<?php
+/**
+*
+* This file is part of the phpBB Forum Software package.
+*
+* @copyright (c) phpBB Limited <https://www.phpbb.com>
+* @license GNU General Public License, version 2 (GPL-2.0)
+*
+* For full copyright and license information, please see
+* the docs/CREDITS.txt file.
+*
+*/
+
+require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php';
+require_once dirname(__FILE__) . '/../../phpBB/includes/functions_content.php';
+
+class phpbb_functions_make_clickable_test extends phpbb_test_case
+{
+ /**
+ * Tags:
+ * 'm' - full URL like xxxx://aaaaa.bbb.cccc.
+ * 'l' - local relative board URL like http://domain.tld/path/to/board/index.php
+ * 'w' - URL without http/https protocol like www.xxxx.yyyy[/zzzz] aka 'lazy' URLs
+ * 'e' - email@domain type address
+ *
+ * Classes:
+ * "postlink-local" for 'l' URLs
+ * "postlink" for the rest of URLs
+ * empty for email addresses
+ **/
+ public function data_test_make_clickable_url_positive()
+ {
+ return array(
+ array(
+ 'http://www.phpbb.com/community/',
+ '<!-- m --><a class="postlink" href="http://www.phpbb.com/community/">http://www.phpbb.com/community/</a><!-- m -->'
+ ),
+ array(
+ 'http://www.phpbb.com/path/file.ext#section',
+ '<!-- m --><a class="postlink" href="http://www.phpbb.com/path/file.ext#section">http://www.phpbb.com/path/file.ext#section</a><!-- m -->'
+ ),
+ array(
+ 'ftp://ftp.phpbb.com/',
+ '<!-- m --><a class="postlink" href="ftp://ftp.phpbb.com/">ftp://ftp.phpbb.com/</a><!-- m -->'
+ ),
+ array(
+ 'sip://bantu@phpbb.com',
+ '<!-- m --><a class="postlink" href="sip://bantu@phpbb.com">sip://bantu@phpbb.com</a><!-- m -->'
+ ),
+ array(
+ 'www.phpbb.com/community/',
+ '<!-- w --><a class="postlink" href="http://www.phpbb.com/community/">www.phpbb.com/community/</a><!-- w -->'
+ ),
+ array(
+ 'http://testhost/viewtopic.php?t=1',
+ '<!-- l --><a class="postlink-local" href="http://testhost/viewtopic.php?t=1">viewtopic.php?t=1</a><!-- l -->'
+ ),
+ array(
+ 'email@domain.com',
+ '<!-- e --><a href="mailto:email@domain.com">email@domain.com</a><!-- e -->'
+ ),
+ // Test appending punctuation mark to the URL
+ array(
+ 'http://testhost/viewtopic.php?t=1!',
+ '<!-- l --><a class="postlink-local" href="http://testhost/viewtopic.php?t=1">viewtopic.php?t=1</a><!-- l -->!'
+ ),
+ array(
+ 'www.phpbb.com/community/?',
+ '<!-- w --><a class="postlink" href="http://www.phpbb.com/community/">www.phpbb.com/community/</a><!-- w -->?'
+ ),
+ // Test shortened text for URL > 55 characters long
+ // URL text should be turned into: first 39 chars + ' ... ' + last 10 chars
+ array(
+ 'http://www.phpbb.com/community/path/to/long/url/file.ext#section',
+ '<!-- m --><a class="postlink" href="http://www.phpbb.com/community/path/to/long/url/file.ext#section">http://www.phpbb.com/community/path/to/ ... xt#section</a><!-- m -->'
+ ),
+
+ // IDN is not parsed and returned as is
+ array('http://домен.рф', 'http://домен.рф'),
+ array('почта@домен.рф', 'почта@домен.рф'),
+ );
+ }
+
+ protected function setUp()
+ {
+ parent::setUp();
+
+ global $config, $user, $request;
+ $user = new phpbb_mock_user();
+ $request = new phpbb_mock_request();
+ }
+
+ /**
+ * @dataProvider data_test_make_clickable_url_positive
+ */
+ public function test_urls_matching_positive($url, $expected)
+ {
+ $this->assertSame($expected, make_clickable($url));
+ }
+}