mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-08 04:18:52 +00:00
Merge branch 'prep-release-3.2.10' into prep-release-3.3.1
This commit is contained in:
commit
3be435561a
7 changed files with 16 additions and 89 deletions
|
@ -391,7 +391,7 @@ class bbcode_firstpass extends bbcode
|
||||||
$in = str_replace(' ', '%20', $in);
|
$in = str_replace(' ', '%20', $in);
|
||||||
|
|
||||||
// Checking urls
|
// Checking urls
|
||||||
if (!preg_match('#^' . get_preg_expression('url') . '$#iu', $in) && !preg_match('#^' . get_preg_expression('www_url') . '$#iu', $in))
|
if (!preg_match('#^' . get_preg_expression('url_http') . '$#iu', $in) && !preg_match('#^' . get_preg_expression('www_url') . '$#iu', $in))
|
||||||
{
|
{
|
||||||
return '[img]' . $in . '[/img]';
|
return '[img]' . $in . '[/img]';
|
||||||
}
|
}
|
||||||
|
@ -402,32 +402,6 @@ class bbcode_firstpass extends bbcode
|
||||||
$in = 'http://' . $in;
|
$in = 'http://' . $in;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($config['max_' . $this->mode . '_img_height'] || $config['max_' . $this->mode . '_img_width'])
|
|
||||||
{
|
|
||||||
$imagesize = new \FastImageSize\FastImageSize();
|
|
||||||
$size_info = $imagesize->getImageSize(htmlspecialchars_decode($in));
|
|
||||||
|
|
||||||
if ($size_info === false)
|
|
||||||
{
|
|
||||||
$error = true;
|
|
||||||
$this->warn_msg[] = $user->lang['UNABLE_GET_IMAGE_SIZE'];
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if ($config['max_' . $this->mode . '_img_height'] && $config['max_' . $this->mode . '_img_height'] < $size_info['height'])
|
|
||||||
{
|
|
||||||
$error = true;
|
|
||||||
$this->warn_msg[] = $user->lang('MAX_IMG_HEIGHT_EXCEEDED', (int) $config['max_' . $this->mode . '_img_height']);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($config['max_' . $this->mode . '_img_width'] && $config['max_' . $this->mode . '_img_width'] < $size_info['width'])
|
|
||||||
{
|
|
||||||
$error = true;
|
|
||||||
$this->warn_msg[] = $user->lang('MAX_IMG_WIDTH_EXCEEDED', (int) $config['max_' . $this->mode . '_img_width']);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($error || $this->path_in_domain($in))
|
if ($error || $this->path_in_domain($in))
|
||||||
{
|
{
|
||||||
return '[img]' . $in . '[/img]';
|
return '[img]' . $in . '[/img]';
|
||||||
|
|
|
@ -185,10 +185,10 @@ $lang = array_merge($lang, array(
|
||||||
'MAX_POLL_OPTIONS' => 'Maximum number of poll options',
|
'MAX_POLL_OPTIONS' => 'Maximum number of poll options',
|
||||||
'MAX_POST_FONT_SIZE' => 'Maximum font size per post',
|
'MAX_POST_FONT_SIZE' => 'Maximum font size per post',
|
||||||
'MAX_POST_FONT_SIZE_EXPLAIN' => 'Maximum font size allowed in a post. Set to 0 for unlimited font size.',
|
'MAX_POST_FONT_SIZE_EXPLAIN' => 'Maximum font size allowed in a post. Set to 0 for unlimited font size.',
|
||||||
'MAX_POST_IMG_HEIGHT' => 'Maximum image height per post',
|
'MAX_POST_IMG_HEIGHT' => 'Maximum flash height per post',
|
||||||
'MAX_POST_IMG_HEIGHT_EXPLAIN' => 'Maximum height of an image/flash file in postings. Set to 0 for unlimited size.',
|
'MAX_POST_IMG_HEIGHT_EXPLAIN' => 'Maximum height of a flash file in postings. Set to 0 for unlimited size.',
|
||||||
'MAX_POST_IMG_WIDTH' => 'Maximum image width per post',
|
'MAX_POST_IMG_WIDTH' => 'Maximum flash width per post',
|
||||||
'MAX_POST_IMG_WIDTH_EXPLAIN' => 'Maximum width of an image/flash file in postings. Set to 0 for unlimited size.',
|
'MAX_POST_IMG_WIDTH_EXPLAIN' => 'Maximum width of a flash file in postings. Set to 0 for unlimited size.',
|
||||||
'MAX_POST_URLS' => 'Maximum links per post',
|
'MAX_POST_URLS' => 'Maximum links per post',
|
||||||
'MAX_POST_URLS_EXPLAIN' => 'Maximum number of URLs in a post. Set to 0 for unlimited links.',
|
'MAX_POST_URLS_EXPLAIN' => 'Maximum number of URLs in a post. Set to 0 for unlimited links.',
|
||||||
'MIN_CHAR_LIMIT' => 'Minimum characters per post/message',
|
'MIN_CHAR_LIMIT' => 'Minimum characters per post/message',
|
||||||
|
|
|
@ -273,8 +273,6 @@ class factory implements \phpbb\textformatter\cache_interface
|
||||||
->add('#imageurl', __NAMESPACE__ . '\\parser::filter_img_url')
|
->add('#imageurl', __NAMESPACE__ . '\\parser::filter_img_url')
|
||||||
->addParameterByName('urlConfig')
|
->addParameterByName('urlConfig')
|
||||||
->addParameterByName('logger')
|
->addParameterByName('logger')
|
||||||
->addParameterByName('max_img_height')
|
|
||||||
->addParameterByName('max_img_width')
|
|
||||||
->markAsSafeAsURL()
|
->markAsSafeAsURL()
|
||||||
->setJS('UrlFilter.filter');
|
->setJS('UrlFilter.filter');
|
||||||
|
|
||||||
|
|
|
@ -380,11 +380,10 @@ class parser implements \phpbb\textformatter\parser_interface
|
||||||
* @param string $url Original URL
|
* @param string $url Original URL
|
||||||
* @param array $url_config Config used by the URL filter
|
* @param array $url_config Config used by the URL filter
|
||||||
* @param Logger $logger
|
* @param Logger $logger
|
||||||
* @param integer $max_height Maximum height allowed
|
*
|
||||||
* @param integer $max_width Maximum width allowed
|
|
||||||
* @return string|bool Original value if valid, FALSE otherwise
|
* @return string|bool Original value if valid, FALSE otherwise
|
||||||
*/
|
*/
|
||||||
static public function filter_img_url($url, array $url_config, Logger $logger, $max_height, $max_width)
|
static public function filter_img_url($url, array $url_config, Logger $logger)
|
||||||
{
|
{
|
||||||
// Validate the URL
|
// Validate the URL
|
||||||
$url = UrlFilter::filter($url, $url_config, $logger);
|
$url = UrlFilter::filter($url, $url_config, $logger);
|
||||||
|
@ -393,29 +392,6 @@ class parser implements \phpbb\textformatter\parser_interface
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($max_height || $max_width)
|
|
||||||
{
|
|
||||||
$imagesize = new \FastImageSize\FastImageSize();
|
|
||||||
$size_info = $imagesize->getImageSize($url);
|
|
||||||
if ($size_info === false)
|
|
||||||
{
|
|
||||||
$logger->err('UNABLE_GET_IMAGE_SIZE');
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($max_height && $max_height < $size_info['height'])
|
|
||||||
{
|
|
||||||
$logger->err('MAX_IMG_HEIGHT_EXCEEDED', array('max_height' => $max_height));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($max_width && $max_width < $size_info['width'])
|
|
||||||
{
|
|
||||||
$logger->err('MAX_IMG_WIDTH_EXCEEDED', array('max_width' => $max_width));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $url;
|
return $url;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -120,6 +120,11 @@ class phpbb_bbcode_parser_test extends \phpbb_test_case
|
||||||
'[img]https://area51.phpbb.com/images/area51.png[/img]',
|
'[img]https://area51.phpbb.com/images/area51.png[/img]',
|
||||||
'[img:]https://area51.phpbb.com/images/area51.png[/img:]',
|
'[img:]https://area51.phpbb.com/images/area51.png[/img:]',
|
||||||
),
|
),
|
||||||
|
array(
|
||||||
|
'Test default bbcodes: img with unsupported protocol',
|
||||||
|
'[img]foo://foo/bar[/img]',
|
||||||
|
'[img]foo://foo/bar[/img]',
|
||||||
|
),
|
||||||
array(
|
array(
|
||||||
'Test default bbcodes: simple url',
|
'Test default bbcodes: simple url',
|
||||||
'[url]https://area51.phpbb.com/[/url]',
|
'[url]https://area51.phpbb.com/[/url]',
|
||||||
|
|
|
@ -132,6 +132,10 @@ class phpbb_textformatter_s9e_default_formatting_test extends phpbb_test_case
|
||||||
'[img]https://area51.phpbb.com/images/area51.png[/img]',
|
'[img]https://area51.phpbb.com/images/area51.png[/img]',
|
||||||
'<img src="https://area51.phpbb.com/images/area51.png" class="postimage" alt="Image">'
|
'<img src="https://area51.phpbb.com/images/area51.png" class="postimage" alt="Image">'
|
||||||
),
|
),
|
||||||
|
array(
|
||||||
|
'[img]foo://area51.phpbb.com/images/area51.png[/img]',
|
||||||
|
'[img]foo://area51.phpbb.com/images/area51.png[/img]'
|
||||||
|
),
|
||||||
array(
|
array(
|
||||||
'[url]https://area51.phpbb.com/[/url]',
|
'[url]https://area51.phpbb.com/[/url]',
|
||||||
'<a href="https://area51.phpbb.com/" class="postlink">https://area51.phpbb.com/</a>'
|
'<a href="https://area51.phpbb.com/" class="postlink">https://area51.phpbb.com/</a>'
|
||||||
|
|
|
@ -342,26 +342,6 @@ class phpbb_text_processing_message_parser_test extends phpbb_test_case
|
||||||
},
|
},
|
||||||
array('You may only use fonts up to size 120.')
|
array('You may only use fonts up to size 120.')
|
||||||
),
|
),
|
||||||
array(
|
|
||||||
'[img]http://example.org/100x100.png[/img]',
|
|
||||||
'<r>[img]<URL url="http://example.org/100x100.png">http://example.org/100x100.png</URL>[/img]</r>',
|
|
||||||
array(true, true, true, true, true, true, true),
|
|
||||||
function ($phpbb_container)
|
|
||||||
{
|
|
||||||
$phpbb_container->get('config')->set('max_post_img_height', 12);
|
|
||||||
},
|
|
||||||
array('Your images may only be up to 12 pixels high.')
|
|
||||||
),
|
|
||||||
array(
|
|
||||||
'[img]http://example.org/100x100.png[/img]',
|
|
||||||
'<r>[img]<URL url="http://example.org/100x100.png">http://example.org/100x100.png</URL>[/img]</r>',
|
|
||||||
array(true, true, true, true, true, true, true),
|
|
||||||
function ($phpbb_container)
|
|
||||||
{
|
|
||||||
$phpbb_container->get('config')->set('max_post_img_width', 34);
|
|
||||||
},
|
|
||||||
array('Your images may only be up to 34 pixels wide.')
|
|
||||||
),
|
|
||||||
array(
|
array(
|
||||||
'[img]http://example.org/100x100.png[/img]',
|
'[img]http://example.org/100x100.png[/img]',
|
||||||
'<r><IMG src="http://example.org/100x100.png"><s>[img]</s><URL url="http://example.org/100x100.png">http://example.org/100x100.png</URL><e>[/img]</e></IMG></r>',
|
'<r><IMG src="http://example.org/100x100.png"><s>[img]</s><URL url="http://example.org/100x100.png">http://example.org/100x100.png</URL><e>[/img]</e></IMG></r>',
|
||||||
|
@ -392,16 +372,6 @@ class phpbb_text_processing_message_parser_test extends phpbb_test_case
|
||||||
$phpbb_container->get('config')->set('max_sig_img_width', 34);
|
$phpbb_container->get('config')->set('max_sig_img_width', 34);
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
array(
|
|
||||||
'[img]http://example.org/404.png[/img]',
|
|
||||||
'<r>[img]<URL url="http://example.org/404.png">http://example.org/404.png</URL>[/img]</r>',
|
|
||||||
array(true, true, true, true, true, true, true),
|
|
||||||
function ($phpbb_container)
|
|
||||||
{
|
|
||||||
$phpbb_container->get('config')->set('max_post_img_height', 12);
|
|
||||||
},
|
|
||||||
array('It was not possible to determine the dimensions of the image.')
|
|
||||||
),
|
|
||||||
array(
|
array(
|
||||||
'[flash=999,999]http://example.org/foo.swf[/flash]',
|
'[flash=999,999]http://example.org/foo.swf[/flash]',
|
||||||
'<r>[flash=999,999]<URL url="http://example.org/foo.swf">http://example.org/foo.swf</URL>[/flash]</r>',
|
'<r>[flash=999,999]<URL url="http://example.org/foo.swf">http://example.org/foo.swf</URL>[/flash]</r>',
|
||||||
|
|
Loading…
Add table
Reference in a new issue