如何回显HTML标记,绕过CMS过滤器

I'm currently working on a site that is locked into an outdated CMS that is licensed from a very uncooperative/unresponsive provider. I need to add rel='canonical' tags to every page but the admin WYSIWYG editor is proving to be a pain. When I switch the the source tab of the editor I can view the code and enter my own additions, but when I click apply many tags are filtered out when I look back in the editor source tab.

It is worth noting I have very limited experience with PHP. That said, I think it may be using something similar to strip_tags to comment out or strip out anything they thought would be an issue. I experimented to see what I could learn from the filter and have posted some relevant results below.

For example: Inputing

<?php
echo "<h2>PHP is Fun!</h2>";
?>

results in this after the change is saved

<!--?php
echo "<h2-->
<p>
    PHP is Fun!&quot;; ?&gt;</p>

And inputting

<?php
echo "<head> <link rel='canonical' href='http://example.com/blog' />"
?>

results in

<!--?php
echo "<head-->
<link href="http://example.com/blog" rel="canonical" />
<p>
    &quot; ?&gt;</p>

So trying to be smart I thought to trick the editor into closing its own comments like this:

<?php
echo "--><?php <head> <link rel='canonical' href='http://example.com/blog' />"

?>

Resulting in

<!--?php
echo "----><!--?php <head-->
<link href="http://example.com/blog" rel="canonical" />
<p>
    &quot; ?&gt;</p>

My observations are that it will begin a replace any opening php tag with an comment beginning in said tag, then finds the next > and uses it to complete the comment. <head></head> gets stripped out completely with any contents being left behind.

Knowing this and seeing the output can any PHP wizards devise a way to beat the commenting AND the stripping of the head tags? I know that having 2 head elements is not valid, but from my research most browsers will accept both and continue.