FormattedText does not allow valueless or data-* attributes
GENERAL
TESTING
GENERAL
TESTING
Description
The attribute parsing in FormattedText does not allow for valueless attributes. These are most commonly used in forms (e.g., checked or selected attributes), and don't cause us trouble there because we do not accept form/input tags (and the XHTML workaround, e.g., checked="checked" is common anyway). However, in HTML5 code, valueless attributes are common. There is a related shortcoming, which is that data-* attributes are not supported.
Supporting data-* attributes is not a simple matter of adding "data-*" to the acceptable attributes list, because of the wildcard. The change to that list is straightforward, adding data(?:-[A-Za-z]), but the parsing must also be changed to account for multiple instances of a pattern. While changing this parsing, it is straightforward to allow valueless attributes.
The goal of supporting data-* attributes is to allow for reasonable widgets to be embedded by the rich text editor with their configuration data inline. The two initial examples of this are better video (YouTube, etc.) embedding and experimentation in supporting mathematical formula rendering (aside from the spotty MathML browser support).
This change is local to FormattedText except for the addition to the allowed attributes in config. It changes the parsing/checking of attributes to be more thorough and allows two constructs that were previously rejected: HTML5 data-* attributes and valueless attributes. The API is unchanged.
There is a new test added to test new and existing attribute patterns. All existing tests are passing and editing with CKEditor behaves the same in basic testing. (Revision 118019)
Result = SUCCESS
Noah Botimer December 30, 2012 at 1:39 PM
Edited
Because my testing was very thorough, including existing and new unit tests, I have checked this in for review on trunk rather than via patches or branches. Please review and test. Behavior should be the same except data- attributes are now accepted along with valueless attributes (e.g., itemscope).
The attribute parsing in FormattedText does not allow for valueless attributes. These are most commonly used in forms (e.g., checked or selected attributes), and don't cause us trouble there because we do not accept form/input tags (and the XHTML workaround, e.g., checked="checked" is common anyway). However, in HTML5 code, valueless attributes are common. There is a related shortcoming, which is that data-* attributes are not supported.
Supporting data-* attributes is not a simple matter of adding "data-*" to the acceptable attributes list, because of the wildcard. The change to that list is straightforward, adding data(?:-[A-Za-z]), but the parsing must also be changed to account for multiple instances of a pattern. While changing this parsing, it is straightforward to allow valueless attributes.
The goal of supporting data-* attributes is to allow for reasonable widgets to be embedded by the rich text editor with their configuration data inline. The two initial examples of this are better video (YouTube, etc.) embedding and experimentation in supporting mathematical formula rendering (aside from the spotty MathML browser support).