Bug 105 started with two similar problems John and Tim had with <goofytext> making its way into their applications, in and out of a database, and back out to the presentation layer, either causing an XML parsing error or a very mangled output stream.
The root of the problem was Marmot’s questionably-intelligent encoding practices. In 1.0.x, Marmot’s add_element would try to encode < and > signs in content, unless it resembled a tag. This was to allow the developer to insert Marmot tags directly in a content string. The two big uses of this were <break /> and <link> tags inserted into paragraphs or other block-level elements. (Also any of the style tags like <bold>.) The problem with this is that it wasn’t any more intelligent than this, so bits of the string’s contents that were not valid tags but somewhat resembled tags, like <user@host.org> or <www.host.com> were not being encoded, causing these non-tags to end up in the XML stream at build time.
This problem was further compounded by 1.1’s new mu_insert_element() function, which would return a stringified representation of a tag. We decided on this as a way to allow developers to insert elements into another element’s content without typing the tags themselves. Today we realized that this only pushed the problem around and didn’t solve anything. The content of one element still contained a stringified representation of another element, which made our encoding decisions even more difficult.
At the same time mu_insert_element() was created, MU_Presentation::make_element() was added to return an unattached element object, exactly like mu_insert_element() returned a string. add_element() was already modified to accept either a string or one of these objects, so it was only logical that we further extend add_element() to accept a string, an object, or an array made of strings and objects. This finally solved our embedded-element issue that plagued us since the beginning. Now, developers do not write tags for Marmot elements by hand, nor do they even have access to string representations of those elements.
The remaining issue is handling cases where this is already being done the wrong way. We are moving forward to document the UBB features to allow developers and users the ability to represent test styles, links, and other basic formatting within strings, for user editing or storage in a database.
Changes for Bug 105 include:
Expanding add_element()’s functionality
Deprecating text2xml(), mu_insert_element(), and the use of tags in a content string