summaryrefslogtreecommitdiff
path: root/inc/common.php
diff options
context:
space:
mode:
authorGuy Brand <gb@unistra.fr>2013-05-10 14:35:28 +0200
committerGuy Brand <gb@unistra.fr>2013-05-10 14:35:28 +0200
commit83f133d10eda8c1c6b6429c08b2d0722ca88ca17 (patch)
tree0377662d2335a0e2160175d5be3b95a92f6bb332 /inc/common.php
parentbc250e0ee2ec4fba891b53aa4f1814ce648ac71a (diff)
parent2a5a1456564635ddbca06edbc902e7f820d2a97b (diff)
downloadrpg-83f133d10eda8c1c6b6429c08b2d0722ca88ca17.tar.gz
rpg-83f133d10eda8c1c6b6429c08b2d0722ca88ca17.tar.bz2
Merge branch master into stable
Diffstat (limited to 'inc/common.php')
-rw-r--r--inc/common.php20
1 files changed, 20 insertions, 0 deletions
diff --git a/inc/common.php b/inc/common.php
index 471eb91b5..4d939ac77 100644
--- a/inc/common.php
+++ b/inc/common.php
@@ -436,6 +436,10 @@ function exportlink($id = '', $format = 'raw', $more = '', $abs = false, $sep =
function ml($id = '', $more = '', $direct = true, $sep = '&amp;', $abs = false) {
global $conf;
if(is_array($more)) {
+ // add token for resized images
+ if($more['w'] || $more['h']){
+ $more['tok'] = media_get_token($id,$more['w'],$more['h']);
+ }
// strip defaults for shorter URLs
if(isset($more['cache']) && $more['cache'] == 'cache') unset($more['cache']);
if(!$more['w']) unset($more['w']);
@@ -443,6 +447,14 @@ function ml($id = '', $more = '', $direct = true, $sep = '&amp;', $abs = false)
if(isset($more['id']) && $direct) unset($more['id']);
$more = buildURLparams($more, $sep);
} else {
+ $matches = array();
+ if (preg_match_all('/\b(w|h)=(\d*)\b/',$more,$matches,PREG_SET_ORDER)){
+ $resize = array('w'=>0, 'h'=>0);
+ foreach ($matches as $match){
+ $resize[$match[1]] = $match[2];
+ }
+ $more .= $sep.'tok='.media_get_token($id,$resize['w'],$resize['h']);
+ }
$more = str_replace('cache=cache', '', $more); //skip default
$more = str_replace(',,', ',', $more);
$more = str_replace(',', $sep, $more);
@@ -777,11 +789,19 @@ function unlock($id) {
/**
* convert line ending to unix format
*
+ * also makes sure the given text is valid UTF-8
+ *
* @see formText() for 2crlf conversion
* @author Andreas Gohr <andi@splitbrain.org>
*/
function cleanText($text) {
$text = preg_replace("/(\015\012)|(\015)/", "\012", $text);
+
+ // if the text is not valid UTF-8 we simply assume latin1
+ // this won't break any worse than it breaks with the wrong encoding
+ // but might actually fix the problem in many cases
+ if(!utf8_check($text)) $text = utf8_encode($text);
+
return $text;
}