diff --git a/lib/plugins/system/meta/HTMLMetaHandler.js b/lib/plugins/system/meta/HTMLMetaHandler.js index e64f6fa1f..7a7c9e54a 100644 --- a/lib/plugins/system/meta/HTMLMetaHandler.js +++ b/lib/plugins/system/meta/HTMLMetaHandler.js @@ -43,156 +43,6 @@ HTMLMetaHandler.prototype.onerror = function(err) { this._callback(err); }; -HTMLMetaHandler.prototype.onopentag = function(name, attributes) { - - if (this._end) return; - - name = name.toUpperCase(); - - if (name === 'META') { - - var metaTag = attributes; - var tagName = metaTag.property || metaTag.name; - - if (tagName) { - - if (/&[^;]+;/i.test(tagName)) { - tagName = decodeHTMLStrict(tagName); - } - var propertyParts = tagName.split(/(?::|\.)/); - - var value = metaTag.content || metaTag.value || metaTag.src; - - if (typeof value === 'string') { - // Remove new lines. - value = value.replace(/(\r\n|\n|\r)/gm, ' '); - } - - if (/^\d+$/.test(value) && !/(title|description)/i.test(tagName)) { // convert to integer - value = parseInt(value, 10); - } else if (/^\d+\.\d+$/.test(value)) { - value = parseFloat(value); - } - - if (typeof value !== 'undefined') { - merge(this._result, propertyParts, value); - } - - } else if (!this._charset && metaTag['http-equiv'] && metaTag['http-equiv'].toLowerCase() == 'content-type') { - - // Set encoding with - this._charset = getCharset(metaTag.content); - - } else if (!this._charset && metaTag['charset']) { - - // Set encoding with . - this._charset = getCharset(metaTag.charset, true); - - } else if (metaTag['http-equiv'] && metaTag['http-equiv'].toLowerCase() == 'x-frame-options') { - - this._customProperties["x-frame-options"] = metaTag.content; - - } else if (!this._refresh && metaTag['http-equiv'] && metaTag['http-equiv'].toLowerCase() == 'refresh') { - - // ex.: http://tv.sme.sk/v/29770/kalinak-o-ficovi-cudujem-sa-ze-vedie-vladu.html - var refresh = metaTag.content && metaTag.content.match(/url=(?:'|")?([^'"]+)(?:'|")?/i); - - if (refresh) { - this._refresh = decodeHTMLStrict(refresh[1]); - } - - } else if (metaTag.name == "description") { - - this._customProperties["html-description"] = metaTag.content; - } - - } else if (name == 'TITLE') { - - this._currentCustomTag = { - name: "html-title", - value: "" - }; - - } else if (name == 'LINK') { - - var metaTag = attributes; - var name = metaTag.name; - var rel = metaTag.rel || name; - var title = metaTag.title; - var sizes = metaTag.sizes; - var type = metaTag.type; - var media = metaTag.media; - var color = metaTag.color; // for SVG - var href; - - if (typeof(metaTag.href) == 'string') { - href = metaTag.href; - } - - if (LINK_REL_SKIP_VALUES.indexOf(rel) == -1) { - var existingProperty = this._customProperties[rel]; - - if (existingProperty && !(existingProperty instanceof Array)) { - existingProperty = this._customProperties[rel] = [existingProperty]; - } - - if (!existingProperty && LINK_REL_ARRAY_VALUES.indexOf(rel) > -1) { - existingProperty = this._customProperties[rel] = []; - } - - var property; - if (type || sizes || media || title || color) { - property = { - href: href - }; - if (type) { - property.type = type; - } - if (sizes) { - property.sizes = sizes; - } - if (media) { - property.media = media; - } - if (title) { - property.title = title; - } - if (color) { - property.color = color; - } - } else { - property = href; - } - - if (existingProperty) { - existingProperty.push(property); - } else { - this._customProperties[rel] = property; - } - } - } else if (name == 'SCRIPT') { - - if (attributes.type === 'application/ld+json') { - - this._currentCustomTag = { - name: "ld-json", - value: "" - } - } - } else if (name === 'HTML') { - - if (attributes.dir) {this._customProperties['dir'] = attributes.dir;} - if (attributes.lang) {this._customProperties['lang'] = attributes.lang;} - - } -}; - -HTMLMetaHandler.prototype.ontext = function(text) { - if (this._currentCustomTag) { - this._currentCustomTag.value += text; - } -}; - HTMLMetaHandler.prototype.onclosetag = function(name) { if (this._end) return;