mason/.perl-lib/TrivGal.pm (Image::scale): Return encoded URL.
authorMark Wooding <mdw@distorted.org.uk>
Sun, 11 Jun 2023 17:42:02 +0000 (18:42 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Mon, 12 Jun 2023 10:48:39 +0000 (11:48 +0100)
Also, apply HTML-encoding as necessary, because I'd failed to do that.

mason/.perl-lib/TrivGal.pm
mason/dhandler

index 600e9f5..eadb8c3 100644 (file)
@@ -219,11 +219,13 @@ package TrivGal::Image {
 
   sub scale ($$) {
     my ($me, $scale) = @_;
+    my $m = HTML::Mason::Request->instance;
 
     my $path = $me->{path};
     my $sz = $SIZE{$scale} or die "unknown scale `$scale'";
     my $thumb = "$CACHE/scale.$sz/$path";
-    my $thumburl = "$CACHEURL/scale.$sz/$path";
+    my $thumburl =
+      $m->interp->apply_escapes("$CACHEURL/scale.$sz/$path", "u");
     my $st = stat $thumb;
     if (defined $st && $st->mtime > $me->{mtime}) { return $thumburl; }
 
index 979419d..91a513b 100755 (executable)
@@ -255,12 +255,12 @@ Failed to find &lsquo;<% $path |h %>&rsquo;.
 % else { $tn = "$STATICURL/folder.svg"; }
 % if ($focus) {
   <figure class="thumb focusthumb <% $size %>">
-    <img class="thumb <% $size %>" load=lazy src="<% $tn |u %>">
+    <img class="thumb <% $size %>" load=lazy src="<% $tn |h %>">
     <figcaption><span class=name><% $caption %></span></figcaption>
 % } else {
   <figure class="thumb <% $size %>">
     <a class=thumb href="<% $target |u %>">
-      <img class="thumb <% $size %>" load=lazy src="<% $tn |u %>">
+      <img class="thumb <% $size %>" load=lazy src="<% $tn |h %>">
       <figcaption>
        <span class=name><% $caption %></span>
 % if (defined $comment) {