Commit 09d71ce3 authored by warp's avatar warp

Bug #233, replace substr() with mb_strcut() to make sure we do not cut the...

Bug #233, replace substr() with mb_strcut() to make sure we do not cut the string in the middle of a unicode sequence.
parent c494501f
......@@ -43,7 +43,7 @@ for($i = 0; $i < count($_POST['a']); $i++) {
switch (mb_detect_encoding($_POST['a'][$i])) {
case "ASCII":
case "UTF-8":
$artist = $adodb->qstr(trim(substr($_POST['a'][$i], 0, 255)));
$artist = $adodb->qstr(trim(mb_strcut($_POST['a'][$i], 0, 255, "UTF-8")));
break;
default:
die("FAILED Bad encoding in artist submission $i\n");
......@@ -53,7 +53,7 @@ for($i = 0; $i < count($_POST['a']); $i++) {
switch (mb_detect_encoding($_POST['b'][$i])) {
case "ASCII":
case "UTF-8":
$album = $adodb->qstr(trim(substr($_POST['b'][$i], 0, 255)));
$album = $adodb->qstr(trim(mb_strcut($_POST['b'][$i], 0, 255, "UTF-8")));
break;
default:
die("FAILED Bad encoding in album submission $i\n");
......@@ -73,7 +73,7 @@ for($i = 0; $i < count($_POST['a']); $i++) {
switch (mb_detect_encoding($_POST['t'][$i])) {
case "ASCII":
case "UTF-8":
$track = $adodb->qstr(trim(substr($_POST['t'][$i], 0, 255)));
$track = $adodb->qstr(trim(mb_strcut($_POST['t'][$i], 0, 255, "UTF-8")));
break;
default:
die("FAILED Bad encoding in title submission $i\n");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment