mdwn: Don't mangle <style> into <elyts> under some circumstances

We can ask libdiscount not to elide <style> blocks, which means we
don't have to work around them.
master
Simon McVittie 2017-05-14 17:45:55 +01:00
parent 5d65c1ad2c
commit 81c3258269
3 changed files with 14 additions and 4 deletions

View File

@ -82,10 +82,15 @@ sub htmlize (@) {
# Workaround for discount's eliding
# of <style> blocks.
# https://rt.cpan.org/Ticket/Display.html?id=74016
$t=~s/<style/<elyts/ig;
my $r=Text::Markdown::Discount::markdown($t, $flags);
$r=~s/<elyts/<style/ig;
return $r;
if (Text::Markdown::Discount->can("MKD_NOSTYLE")) {
$flags |= Text::Markdown::Discount::MKD_NOSTYLE();
}
else {
# This is correct for the libmarkdown.so.2 ABI
$flags |= 0x00400000;
}
return Text::Markdown::Discount::markdown($t, $flags);
}
}
}

1
debian/changelog vendored
View File

@ -7,6 +7,7 @@ ikiwiki (3.20170112) UNRELEASED; urgency=medium
misconfigured nginx servers, and in general treat sessions with
a set-but-empty name as if they were not signed in.
* When the CGI fails, print the error to stderr, not "Died"
* mdwn: Don't mangle <style> into <elyts> under some circumstances
-- Simon McVittie <smcv@debian.org> Sun, 14 May 2017 15:34:52 +0100

View File

@ -28,3 +28,7 @@ discuss style markup several times. The first couple of times I saw this happen,
I thought it was some sort of misguided anti-cross-site-scripting filter...
--[[smcv]]
> [[Fixed|done]] by passing the `MKD_NOSTYLE` flag to Discount instead.
> Unfortunately this isn't bound by [[!cpan Text::Markdown::Discount]] yet,
> so for now I'm hard-coding its numeric value. --[[smcv]]