Rename data-mw into data-rt

This hopefully makes it clearer that data-rt contains private round-trip info
instead of semantically interesting data.

Change-Id: I03b476ed112a4b627c9871ee3677c450f943429a
This commit is contained in:
Gabriel Wicke 2012-07-16 12:10:08 -07:00
parent 2faba528aa
commit 3172afb750
6 changed files with 9 additions and 9 deletions

View file

@ -86,7 +86,7 @@ Sanitizer.prototype._stripIDNs = function ( host ) {
* Sanitize any tag.
*
* XXX: Make attribute sanitation reversible by storing round-trip info in
* token.dataAttribs object (which is serialized as JSON in a data-mw
* token.dataAttribs object (which is serialized as JSON in a data-rt
* attribute in the DOM).
*/
Sanitizer.prototype.onAny = function ( token ) {

View file

@ -81,7 +81,7 @@ FauxHTML5.TreeBuilder.prototype.processToken = function (token) {
attribs = attribs.concat([
{
// Mediawiki-specific round-trip / non-semantic information
k: 'data-mw',
k: 'data-rt',
v: dataMW
} ] );
}

View file

@ -90,7 +90,7 @@ var annotationTypes = {
'span': 'textStyle/span',
'a': function( node ) {
// FIXME the parser currently doesn't output this data this way
// Internal links get linkType:'internal' in the data-mw-rt attrib,
// Internal links get linkType:'internal' in the data-rt attrib,
// external links get nothing
var atype = node.getAttribute( 'data-type' );
if ( atype ) {

View file

@ -654,7 +654,7 @@ WSP.tagHandlers = {
if ( state.prevToken.constructor === TagTk && state.prevToken.name === 'tbody' ) {
// Omit for first row in a table. XXX: support optional trs
// for first line (in source wikitext) too using some flag in
// data-mw (stx: 'wikitext' ?)
// data-rt (stx: 'wikitext' ?)
return '';
} else {
return WSP._serializeTableTag("|-", '', state, token );
@ -1300,7 +1300,7 @@ WSP._getDOMAttribs = function( attribs ) {
var out = [];
for ( var i = 0, l = attribs.length; i < l; i++ ) {
var attrib = attribs.item(i);
if ( attrib.name !== 'data-mw' ) {
if ( attrib.name !== 'data-rt' ) {
out.push( { k: attrib.name, v: attrib.value } );
}
}
@ -1308,8 +1308,8 @@ WSP._getDOMAttribs = function( attribs ) {
};
WSP._getDOMRTInfo = function( attribs ) {
if ( attribs['data-mw'] ) {
return JSON.parse( attribs['data-mw'].value || '{}' );
if ( attribs['data-rt'] ) {
return JSON.parse( attribs['data-rt'].value || '{}' );
} else {
return {};
}

View file

@ -51,7 +51,7 @@ testWhiteList["Invalid attributes in table cell (bug 1830)"] = "<table><tbody><t
testWhiteList["Table security: embedded pipes (http://lists.wikimedia.org/mailman/htdig/wikitech-l/2006-April/022293.html)"] = "<table><tbody><tr><td> |<a href=\"ftp://|x||\">[1]</a>\" onmouseover=\"alert(document.cookie)\"&gt;test</td></tr></tbody></table>";
// Sanitizer, but UTF8 in link is ok in HTML5
testWhiteList["External link containing double-single-quotes with no space separating the url from text in italics"] = "<p><a href=\"http://www.musee-picasso.fr/pages/page_id18528_u1l2.htm\" data-mw=\"{&quot;sourcePos&quot;:[0,146]}\"><i>La muerte de Casagemas</i> (1901) en el sitio de </a><a href=\"/wiki/Museo_Picasso_(París)\">Museo Picasso</a>.</p>";
testWhiteList["External link containing double-single-quotes with no space separating the url from text in italics"] = "<p><a href=\"http://www.musee-picasso.fr/pages/page_id18528_u1l2.htm\" data-rt=\"{&quot;sourcePos&quot;:[0,146]}\"><i>La muerte de Casagemas</i> (1901) en el sitio de </a><a href=\"/wiki/Museo_Picasso_(París)\">Museo Picasso</a>.</p>";
testWhiteList["External links: wiki links within external link (Bug 3695)"] = "<p><a href=\"http://example.com\"></a><a href=\"/wiki/Wikilink\">wikilink</a> embedded in ext link</p>";

View file

@ -340,7 +340,7 @@ ParserTests.prototype.normalizeOut = function ( out ) {
return out
.replace(/<span data-gen=[^>]*>((?:[^<]+|(?!<\/span).)*)<\/span>/g,
'$1')
.replace(/[\r\n]| (data-mw|typeof|resource|rel|prefix|about|rev|datatype|inlist|property|vocab|content)="[^">]*"/g, '')
.replace(/[\r\n]| (data-rt|typeof|resource|rel|prefix|about|rev|datatype|inlist|property|vocab|content)="[^">]*"/g, '')
.replace(/<!--.*?-->\n?/gm, '')
.replace(/<\/?meta[^>]*>/g, '');
};