mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-22 04:39:55 +09:00
17223554 : xquared upgrade to 0.7
git-svn-id: http://xe-core.googlecode.com/svn/sandbox@4968 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
parent
5956e254e7
commit
7c3b336e41
59 changed files with 34562 additions and 8454 deletions
|
|
@ -0,0 +1,75 @@
|
|||
/**
|
||||
* @requires Xquared.js
|
||||
* @requires validator/Base.js
|
||||
*/
|
||||
xq.validator.Trident = xq.Class(xq.validator.Base,
|
||||
/**
|
||||
* @name xq.validator.Trident
|
||||
* @lends xq.validator.Trident.prototype
|
||||
* @extends xq.validator.Base
|
||||
* @constructor
|
||||
*/
|
||||
{
|
||||
validateDom: function(element) {
|
||||
this.removeDangerousElements(element);
|
||||
this.validateFont(element);
|
||||
},
|
||||
|
||||
validateString: function(html) {
|
||||
try {
|
||||
html = this.validateStrike(html);
|
||||
html = this.validateUnderline(html);
|
||||
html = this.performFullValidation(html);
|
||||
} catch(ignored) {}
|
||||
|
||||
return html;
|
||||
},
|
||||
|
||||
invalidateDom: function(element) {
|
||||
this.invalidateFont(element);
|
||||
this.invalidateStrikesAndUnderlines(element);
|
||||
},
|
||||
|
||||
invalidateString: function(html) {
|
||||
html = this.removeComments(html);
|
||||
return html;
|
||||
},
|
||||
|
||||
performFullValidation: function(html) {
|
||||
html = this.lowerTagNamesAndUniformizeQuotation(html);
|
||||
html = this.validateSelfClosingTags(html);
|
||||
html = this.applyWhitelist(html);
|
||||
|
||||
if(this.urlValidationMode === 'relative') {
|
||||
html = this.makeUrlsRelative(html);
|
||||
} else if(this.urlValidationMode === 'host_relative') {
|
||||
html = this.makeUrlsHostRelative(html);
|
||||
} else if(this.urlValidationMode === 'absolute') {
|
||||
// Trident always use absolute URL so we don't need to do anything.
|
||||
//
|
||||
// html = this.makeUrlsAbsolute(html);
|
||||
}
|
||||
|
||||
return html;
|
||||
},
|
||||
|
||||
lowerTagNamesAndUniformizeQuotation: function(html) {
|
||||
this.pAttrQuotation1 = xq.compilePattern("\\s(\\w+?)=\\s+\"([^\"]+)\"", "mg");
|
||||
this.pAttrQuotation2 = xq.compilePattern("\\s(\\w+?)=([^ \"]+)", "mg");
|
||||
this.pAttrQuotation3 = xq.compilePattern("\\sNAME=\"(\\w+?)\" VALUE=\"(\\w+?)\"", "mg");
|
||||
|
||||
// Uniformize quotation, turn tag names and attribute names into lower case
|
||||
html = html.replace(/<(\/?)(\w+)([^>]*?)>/img, function(str, closingMark, tagName, attrs) {
|
||||
return "<" + closingMark + tagName.toLowerCase() + this.correctHtmlAttrQuotation(attrs) + ">";
|
||||
}.bind(this));
|
||||
|
||||
return html;
|
||||
},
|
||||
|
||||
correctHtmlAttrQuotation: function(html) {
|
||||
html = html.replace(this.pAttrQuotation1, function (str, name, value) {return " " + name.toLowerCase() + '=' + '"' + value + '"'});
|
||||
html = html.replace(this.pAttrQuotation2, function (str, name, value) {return " " + name.toLowerCase() + '=' + '"' + value + '"'});
|
||||
html = html.replace(this.pAttrQuotation3, function (str, name, value) {return " name=\"" + name + "\" value=\"" + value + "\""});
|
||||
return html;
|
||||
}
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue