WordPress HTML markup breaks plugin shortcodes

I was extending a WordPress plugin (I don’t think the actual plugin matters but it was the very useful posts-in-page plugin). It has a loop (posts_loop_template.php) that displays the posts on a page. We need this for a web shop.

On the page I had the plugin shortcode, [ic_add_posts thumbnail=’thumbnail’ showposts=’5′ postlink=’1′ layout=’0′ metacats=’0′ metacomments=’0′] as shown and in bold (for no particular reason).

I noticed that my code changes had stopped working.  An hour or so ago they had worked but after adding some of the new options they stopped working. I removed the plugin and added it back (it started working) and then I added back my edits and managed to trigger the problem again. This time I had more data and it was obvious what had gone wrong. When I added in the shortcode options then when you look at the “Text” version I saw that the new option had html markup around it,

<strong><strong>[ic_add_posts thumbnail='thumbnail' showposts='5' postlink='1' 
layout='0' metacats='0' <strong>metacomments='0'</strong>]</strong>
 </strong>

This caused the option arguments to be parsed wrong by WordPress – or perhaps correctly but it wasn’t what I wanted. The options array ended up like this and you can see the “metacomments” option was not parsed but is in the array as [0] => metacomments=’0′ and not [metacomments] => 0

Array ( [post_type] => post [post_status] => publish [orderby] => date 
[order] => DESC [template] => [posts_per_page] => 5 [thumbnail] => thumbnail 
[showposts] => 5 [postlink] => 1 [layout] => 0 
[metacats] => 0 [0] => metacomments='0' [post__not_in] => Array ( ) ) 

When I removed the html formatting from around the plugin shortcode then it worked perfectly. As a guess WordPress should strip tags but that may have backward compatibility issues.