login: support eol in text configuration files
authorMischa POSLAWSKY <perl@shiar.org>
Mon, 12 Nov 2018 20:03:27 +0000 (21:03 +0100)
committerMischa POSLAWSKY <perl@shiar.org>
Tue, 13 Nov 2018 17:50:31 +0000 (18:50 +0100)
auth.inc.php
login/edit.php

index a2db9f31f1b385b8284c5a97360ed6edeb35abbb..65b7f72571b9123f036a39b845f82fa93e7fdb1e 100644 (file)
@@ -19,7 +19,7 @@ class User
 
        function rawname()
        {
-               return @file_get_contents("{$this->dir}/name.txt");
+               return rtrim(@file_get_contents("{$this->dir}/name.txt"));
        }
 
        function name()
index 99afb13a62b745cfe08068c340815aa480cb1ff4..e60cf59bb046414c705bf1df138817f456e44e95 100644 (file)
@@ -57,7 +57,7 @@ foreach ($cols as $col => &$colconf) {
        $colpath = $user['dir'] . '/' . $colconf['filename'];
        if (file_exists($colpath)) {
                $colconf['value'] = $filetype != 'txt' ? '' :
-                       file_get_contents($colpath);
+                       rtrim(file_get_contents($colpath));
        }
        if (file_exists($user['dir']) and !is_writable($user['dir'])) {
                continue;  # locked parent directory
@@ -122,6 +122,9 @@ if ($_POST) {
                        }
                        continue;
                }
+               if (@$cols[$col]['type'] != 'file') {
+                       $val .= "\n"; # eol in text files
+               }
                if (file_put_contents($cols[$col]['target'], $val) === FALSE) {
                        $colwarn[$col] = "Fout bij opslaan.";
                }