]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/commitdiff
mdwn: Don't mangle <style> into <elyts> under some circumstances
authorSimon McVittie <smcv@debian.org>
Sun, 14 May 2017 16:45:55 +0000 (17:45 +0100)
committerSimon McVittie <smcv@debian.org>
Sun, 14 May 2017 16:45:55 +0000 (17:45 +0100)
We can ask libdiscount not to elide <style> blocks, which means we
don't have to work around them.

IkiWiki/Plugin/mdwn.pm
debian/changelog
doc/bugs/escaped_style_tag_becomes_elyts.mdwn

index 436f2461da9399cd7d80aaf09d42f06c2391f59a..aeb3a3fd7f6aabf72a01248e45036da01257a1d5 100644 (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);
                                }
                        }
                }
index a92e3711e5f8d44e5dd8337ccb05bd2dcc5e1dea..08e320f30945d84ee6bcfaaf00569b79fafa2500 100644 (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
 
index 709542527a726a0b60a331f65c49a3a5579840c9..336e2ff953654e6b16c1bb70e3b7ae234ef80705 100644 (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]]