foto: escape html (ampersands) in album links
authorMischa POSLAWSKY <perl@shiar.org>
Fri, 15 Jan 2021 10:23:19 +0000 (11:23 +0100)
committerMischa POSLAWSKY <perl@shiar.org>
Sat, 23 Jan 2021 12:56:54 +0000 (13:56 +0100)
Fix broken entity Lijtweg directory <verbouw&opknap>.

foto/index.php

index a6378ef8f393487113b64b430a121adb4d33d511..49e5483d24d4d23ecaa8b0b3dbc078d8a49cd759 100644 (file)
@@ -72,22 +72,22 @@ if ($imgs = glob("$rootdir/*", GLOB_ONLYDIR)) {
        natsort($imgs);
        print '<ul class="gallery cat">'."\n";
        foreach ($imgs as $path) {
-               $parts = pathinfo($path);
-               $album = $parts['filename'];
+               $album = htmlspecialchars(pathinfo($path, PATHINFO_FILENAME));
                $cover = "$path/index.jpg";
                if (!file_exists($cover)) $cover = 'foto/index.jpg';
                if (is_link($cover)) {
                        $cover = preg_replace('{^(?:\.\./)*(?=data/)}', 'thumb/100/', readlink($cover));
                }
 
-               $html = '<img src="/'.$cover.'" />';
+               $html = sprintf('<img src="/%s" />', htmlspecialchars($cover));
                $html .= "<figcaption>$album</figcaption>";
                if (!$User->login and file_exists("$path/.private")) {
                        $html = '<s title="bewoners">'.$html.'</s>';
                }
                $html = "<figure>$html</figure>";
 
-               printf('<li id="%s"><a href="%s">%s</a>'."\n", $album, "/$path", $html);
+               printf('<li id="%s">', $album);
+               printf('<a href="/%s">%s</a>'."\n", htmlspecialchars($path), $html);
        }
        print "</ul>\n\n";
 }