disallow illegal characters inside sections in attributes, and error on open/close mismatch

This PR addresses #875 - mismatched opening/closing section tags inside an attribute value now throw an error. This requires another fix, which is that characters that are illegal inside attributes should still be illegal when they're inside a *section* inside said attribute - an oversight that had somehow gone unnoticed thus far.