FormattedText does not allow valueless or data-* attributes

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).

Activity

Anthony Whyte April 1, 2013 at 7:29 PM
Edited

Merged config 2.9.x r122042.
Merged kernel 1.3.x r122044.

Aaron Zeckoski January 2, 2013 at 5:16 AM

Looks good to me

Hudson CI Server December 30, 2012 at 2:15 PM

Integrated in kernel-trunk #577 (See http://builds.sakaiproject.org:8080/job/kernel-trunk/577/)
Add support for HTML5 data-* and valueless attributes

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).

Fixed

Details

Priority

Affects versions

Fix versions

Components

Assignee

Reporter

Created December 30, 2012 at 11:03 AM
Updated April 25, 2018 at 3:19 PM
Resolved December 30, 2012 at 1:39 PM