Browse Source

Fix last commit; Make Tinyboard Twig extension more mb-safe

pull/40/head
Michael Foster 11 years ago
parent
commit
6cdf603875
  1. 8
      inc/lib/Twig/Extensions/Extension/Tinyboard.php
  2. 4
      templates/post_thread.html

8
inc/lib/Twig/Extensions/Extension/Tinyboard.php

@ -83,9 +83,9 @@ function twig_hasPermission_filter($mod, $permission, $board = null) {
}
function twig_extension_filter($value, $case_insensitive = true) {
$ext = substr($value, strrpos($value, '.') + 1);
$ext = mb_substr($value, mb_strrpos($value, '.') + 1);
if($case_insensitive)
$ext = strtolower($ext);
$ext = mb_strtolower($ext);
return $ext;
}
@ -96,11 +96,11 @@ function twig_sprintf_filter( $value, $var) {
function twig_truncate_filter($value, $length = 30, $preserve = false, $separator = '…') {
if (mb_strlen($value) > $length) {
if ($preserve) {
if (false !== ($breakpoint = strpos($value, ' ', $length))) {
if (false !== ($breakpoint = mb_strpos($value, ' ', $length))) {
$length = $breakpoint;
}
}
return substr($value, 0, $length) . $separator;
return mb_substr($value, 0, $length) . $separator;
}
return $value;
}

4
templates/post_thread.html

@ -23,9 +23,9 @@
{% if config.show_filename and post.filename %}
,
{% if post.filename|length > config.max_filename_display %}
<span class="postfilename" title="{{ post.filename|bidi_cleanup }}">{{ post.filename|truncate(config.max_filename_display)|bidi_cleanup }}</span>
<span class="postfilename" title="{{ post.filename|e|bidi_cleanup }}">{{ post.filename|truncate(config.max_filename_display)|bidi_cleanup }}</span>
{% else %}
<span class="postfilename">{{ post.filename|bidi_cleanup }}</span>
<span class="postfilename">{{ post.filename|e|bidi_cleanup }}</span>
{% endif %}
{% endif %}
{% if post.thumb != 'file' and config.image_identification %}

Loading…
Cancel
Save