aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon McVittie <smcv@debian.org>2017-05-14 17:45:55 +0100
committerSimon McVittie <smcv@debian.org>2017-05-14 17:45:55 +0100
commit81c3258269fa53684043ce5b9fd701bb6a381017 (patch)
tree41caeb452a1881245fc523845d7b733bc79fd396
parent5d65c1ad2c1d4a39dcb8c36d6ae6e4d458ed829f (diff)
downloadikiwiki-81c3258269fa53684043ce5b9fd701bb6a381017.tar
ikiwiki-81c3258269fa53684043ce5b9fd701bb6a381017.tar.gz
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.
-rw-r--r--IkiWiki/Plugin/mdwn.pm13
-rw-r--r--debian/changelog1
-rw-r--r--doc/bugs/escaped_style_tag_becomes_elyts.mdwn4
3 files changed, 14 insertions, 4 deletions
diff --git a/IkiWiki/Plugin/mdwn.pm b/IkiWiki/Plugin/mdwn.pm
index 436f2461d..aeb3a3fd7 100644
--- a/IkiWiki/Plugin/mdwn.pm
+++ b/IkiWiki/Plugin/mdwn.pm
@@ -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);
}
}
}
diff --git a/debian/changelog b/debian/changelog
index a92e3711e..08e320f30 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -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
diff --git a/doc/bugs/escaped_style_tag_becomes_elyts.mdwn b/doc/bugs/escaped_style_tag_becomes_elyts.mdwn
index 709542527..336e2ff95 100644
--- a/doc/bugs/escaped_style_tag_becomes_elyts.mdwn
+++ b/doc/bugs/escaped_style_tag_becomes_elyts.mdwn
@@ -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]]