#702841 blosxom: Template interpolation ignores $blog_encoding

#702841#5
Date:
2013-03-12 03:55:47 UTC
From:
To:
In the default output i found...

<meta http-equiv="content-type" content="text/html; charset=$blog_encoding" >

Where $blog_encoding is actually a default variable.

Looking at the interpolate subroutine...

    $interpolate = sub {
        package blosxom;
        my $template = shift;
        # Interpolate scalars, namespaced scalars, and hash/hashref scalars
        $template =~ s/(\$\w+(?:::\w+)*(?:(?:->)?{(['"]?)[-\w]+\2})?)/"defined $1 ? $1 : ''"/gee;
        return $template;
    };


the substitute regular expression doesnt seem to include underscore.

absolutely though, its not picking up $blog_encoding as it should at least be replacing it with ''

#702841#10
Date:
2013-03-12 12:18:11 UTC
From:
To:
Hi Dean,

Dean Hamstead wrote:

Oops. Thanks for the bug report.

And thanks for the analysis. Sounds reasonable at a first glance. Then
on the other hand, this works for me:

<meta name="description" lang="en" content="$blog_description" />

It becomes as expected:

<meta name="description" lang="en" content="Yet another Blosxom weblog from someone who promised himself to never start blogging - since blogging is futile." />

Reason why this works is because \w already includes underscore. From
perlre(1):

           \w       Match a "word" character (alphanumeric plus "_")

So the problem resides somewhere else.

You've got a point there.

		Regards, Axel

#702841#15
Date:
2025-09-17 10:08:43 UTC
From:
To:
Invesitgating this as a Bug of the Day the cause appears to be due to it not
doing recursive interpolation.

At line 512 `$content_type` is set from the template HTTP header in blosxom.cgi in
its __DATA__ template at line 787 to

`text/html; charset=$blog_encoding`

Then in line 792 it has:

`html head         <meta http-equiv="content-type" content="$content_type" >`

so in function `generate()` the Interpolate sub at line 564 does replacement,
sees `$content_type` and replaces it with that variable's value but does not then
recurse the result to interpolate the included `$blog_encoding`