From: Mischa POSLAWSKY Date: Sun, 8 Jul 2018 15:18:23 +0000 (+0200) Subject: login/edit: filter to replace newlines in input values X-Git-Tag: v3.5~18 X-Git-Url: http://git.shiar.net/minimedit.git/commitdiff_plain/6ae2047b653270d73708f9793518b4feb9c2a4fd login/edit: filter to replace newlines in input values Multiple names on Lijtweg. --- diff --git a/login/edit.php b/login/edit.php index 46b6132..6f3eff2 100644 --- a/login/edit.php +++ b/login/edit.php @@ -17,6 +17,7 @@ $cols = [ 'name' => [ 'label' => 'volledige naam', 'explain' => "Alleen zichtbaar voor andere leden.", + 'filter' => ["\n", '; '], ], 'email' => [ 'label' => 'e-mailadres', @@ -134,6 +135,11 @@ if ($_POST) { } continue; } + + if (isset($cols[$col]['filter'])) { + list ($targetstr, $inputstr) = $cols[$col]['filter']; + $val = str_replace($inputstr, $targetstr, $val); + } if (isset($cols[$col]['value']) and $cols[$col]['value'] === $val) { continue; # unaltered } @@ -230,6 +236,11 @@ foreach ($cols as $col => &$colconf) { } } else { + if (isset($cols[$col]['filter'])) { + list ($targetstr, $inputstr) = $cols[$col]['filter']; + $colconf['value'] = str_replace($targetstr, $inputstr, $colconf['value']); + } + $attrs = [ 'type' => @$colconf['type'] ?: 'text', 'name' => $col,