aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--phpBB/includes/ucp/ucp_pm_compose.php6
-rw-r--r--phpBB/phpbb/textformatter/s9e/utils.php5
-rw-r--r--phpBB/posting.php4
-rw-r--r--tests/functional/private_messages_test.php2
-rw-r--r--tests/text_formatter/s9e/default_formatting_test.php4
-rw-r--r--tests/text_formatter/s9e/utils_test.php15
6 files changed, 29 insertions, 7 deletions
diff --git a/phpBB/includes/ucp/ucp_pm_compose.php b/phpBB/includes/ucp/ucp_pm_compose.php
index 61dab982df..0989539a0f 100644
--- a/phpBB/includes/ucp/ucp_pm_compose.php
+++ b/phpBB/includes/ucp/ucp_pm_compose.php
@@ -942,10 +942,10 @@ function compose_pm($id, $mode, $action, $user_folders = array())
$message_link = '';
}
$quote_text = $phpbb_container->get('text_formatter.utils')->generate_quote(
- censor_text(trim($message_parser->message)),
+ censor_text($message_parser->message),
array('author' => $quote_username)
);
- $message_parser->message = $message_link . $quote_text . "\n";
+ $message_parser->message = $message_link . $quote_text . "\n\n";
}
if (($action == 'reply' || $action == 'quote' || $action == 'quotepost') && !$preview && !$refresh)
@@ -974,7 +974,7 @@ function compose_pm($id, $mode, $action, $user_folders = array())
$forward_text[] = sprintf($user->lang['FWD_TO'], implode($user->lang['COMMA_SEPARATOR'], $fwd_to_field['to']));
$quote_text = $phpbb_container->get('text_formatter.utils')->generate_quote(
- censor_text(trim($message_parser->message)),
+ censor_text($message_parser->message),
array('author' => $quote_username)
);
$message_parser->message = implode("\n", $forward_text) . "\n\n" . $quote_text;
diff --git a/phpBB/phpbb/textformatter/s9e/utils.php b/phpBB/phpbb/textformatter/s9e/utils.php
index 04df589930..803c71a5a2 100644
--- a/phpBB/phpbb/textformatter/s9e/utils.php
+++ b/phpBB/phpbb/textformatter/s9e/utils.php
@@ -56,6 +56,7 @@ class utils implements \phpbb\textformatter\utils_interface
*/
public function generate_quote($text, array $attributes = array())
{
+ $text = trim($text);
$quote = '[quote';
if (isset($attributes['author']))
{
@@ -67,7 +68,9 @@ class utils implements \phpbb\textformatter\utils_interface
{
$quote .= ' ' . $name . '=' . $this->enquote($value);
}
- $quote .= ']' . $text . '[/quote]';
+ $quote .= ']';
+ $newline = (strlen($quote . $text . '[/quote]') > 80 || strpos($text, "\n") !== false) ? "\n" : '';
+ $quote .= $newline . $text . $newline . '[/quote]';
return $quote;
}
diff --git a/phpBB/posting.php b/phpBB/posting.php
index 48c7c36690..2f9beefcf9 100644
--- a/phpBB/posting.php
+++ b/phpBB/posting.php
@@ -1604,10 +1604,10 @@ if ($generate_quote)
if ($config['allow_bbcode'])
{
$message_parser->message = $phpbb_container->get('text_formatter.utils')->generate_quote(
- censor_text(trim($message_parser->message)),
+ censor_text($message_parser->message),
array('author' => $post_data['quote_username'])
);
- $message_parser->message .= "\n";
+ $message_parser->message .= "\n\n";
}
else
{
diff --git a/tests/functional/private_messages_test.php b/tests/functional/private_messages_test.php
index 3f602d62fb..be584c20c1 100644
--- a/tests/functional/private_messages_test.php
+++ b/tests/functional/private_messages_test.php
@@ -84,7 +84,7 @@ class phpbb_functional_private_messages_test extends phpbb_functional_test_case
public function test_quote_forward()
{
$text = 'This is a test private message sent by the testing framework.';
- $expected = '[quote="admin"]' . $text . '[/quote]';
+ $expected = "[quote=\"admin\"]\n" . $text . "\n[/quote]";
$this->login();
$message_id = $this->create_private_message('Test', $text, array(2));
diff --git a/tests/text_formatter/s9e/default_formatting_test.php b/tests/text_formatter/s9e/default_formatting_test.php
index 2aa15146aa..67921d5b1e 100644
--- a/tests/text_formatter/s9e/default_formatting_test.php
+++ b/tests/text_formatter/s9e/default_formatting_test.php
@@ -221,6 +221,10 @@ class phpbb_textformatter_s9e_default_formatting_test extends phpbb_test_case
'[quote="http://example.org"]...[/quote]',
'<blockquote><div><cite><a href="http://example.org" class="postlink">http://example.org</a> wrote:</cite>...</div></blockquote>'
),
+ array(
+ "[quote]\nThis is a long quote that is definitely going to exceed 80 characters\n[/quote]\n\nFollowed by a reply",
+ "<blockquote class=\"uncited\"><div>\nThis is a long quote that is definitely going to exceed 80 characters\n</div></blockquote>\n\nFollowed by a reply"
+ ),
);
}
}
diff --git a/tests/text_formatter/s9e/utils_test.php b/tests/text_formatter/s9e/utils_test.php
index 555f29cb38..152c316b2e 100644
--- a/tests/text_formatter/s9e/utils_test.php
+++ b/tests/text_formatter/s9e/utils_test.php
@@ -171,6 +171,21 @@ class phpbb_textformatter_s9e_utils_test extends phpbb_test_case
),
'[quote="user" post_id="123" url="http://example.org"]...[/quote]',
),
+ array(
+ 'This is a long quote that is definitely going to exceed 80 characters',
+ array(),
+ "[quote]\nThis is a long quote that is definitely going to exceed 80 characters\n[/quote]",
+ ),
+ array(
+ ' This is a short quote on its own line ',
+ array(),
+ '[quote]This is a short quote on its own line[/quote]',
+ ),
+ array(
+ "This is a short quote\non two lines",
+ array(),
+ "[quote]\nThis is a short quote\non two lines\n[/quote]",
+ ),
);
}