Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

simple-html-tokenizer

Package Overview
Dependencies
Maintainers
6
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

simple-html-tokenizer - npm Package Compare versions

Comparing version 0.5.7 to 0.5.8

37

dist/es6/index.js

@@ -62,3 +62,3 @@ /**

var char = this.peek();
if (char === '<') {
if (char === '<' && !this.isIgnoredEndTag()) {
this.transitionTo("tagOpen" /* tagOpen */);

@@ -81,3 +81,4 @@ this.markTagStart();

var char = this.peek();
if (char === '<') {
var tag = this.tagNameBuffer.toLowerCase();
if (char === '<' && !this.isIgnoredEndTag()) {
this.delegate.finishData();

@@ -88,3 +89,3 @@ this.transitionTo("tagOpen" /* tagOpen */);

}
else if (char === '&') {
else if (char === '&' && tag !== 'script' && tag !== 'style') {
this.consume();

@@ -115,3 +116,3 @@ this.delegate.appendToData(this.consumeCharRef() || '&');

var char = this.consume();
if (char === '-' && this.input.charAt(this.index) === '-') {
if (char === '-' && this.peek() === '-') {
this.consume();

@@ -196,2 +197,21 @@ this.transitionTo("commentStart" /* commentStart */);

},
endTagName: function () {
var char = this.consume();
if (isSpace(char)) {
this.transitionTo("beforeAttributeName" /* beforeAttributeName */);
this.tagNameBuffer = '';
}
else if (char === '/') {
this.transitionTo("selfClosingStartTag" /* selfClosingStartTag */);
this.tagNameBuffer = '';
}
else if (char === '>') {
this.delegate.finishTag();
this.transitionTo("beforeData" /* beforeData */);
this.tagNameBuffer = '';
}
else {
this.appendToTagName(char);
}
},
beforeAttributeName: function () {

@@ -405,3 +425,3 @@ var char = this.peek();

if (char === '@' || char === ':' || isAlpha(char)) {
this.transitionTo("tagName" /* tagName */);
this.transitionTo("endTagName" /* endTagName */);
this.tagNameBuffer = '';

@@ -418,2 +438,3 @@ this.delegate.beginEndTag();

this.input = '';
this.tagNameBuffer = '';
this.index = 0;

@@ -494,2 +515,8 @@ this.line = 1;

};
EventedTokenizer.prototype.isIgnoredEndTag = function () {
var tag = this.tagNameBuffer.toLowerCase();
return (tag === 'title' && this.input.substring(this.index, this.index + 8) !== '</title>') ||
(tag === 'style' && this.input.substring(this.index, this.index + 8) !== '</style>') ||
(tag === 'script' && this.input.substring(this.index, this.index + 9) !== '</script>');
};
return EventedTokenizer;

@@ -496,0 +523,0 @@ }());

@@ -68,3 +68,3 @@ (function (global, factory) {

var char = this.peek();
if (char === '<') {
if (char === '<' && !this.isIgnoredEndTag()) {
this.transitionTo("tagOpen" /* tagOpen */);

@@ -87,3 +87,4 @@ this.markTagStart();

var char = this.peek();
if (char === '<') {
var tag = this.tagNameBuffer.toLowerCase();
if (char === '<' && !this.isIgnoredEndTag()) {
this.delegate.finishData();

@@ -94,3 +95,3 @@ this.transitionTo("tagOpen" /* tagOpen */);

}
else if (char === '&') {
else if (char === '&' && tag !== 'script' && tag !== 'style') {
this.consume();

@@ -121,3 +122,3 @@ this.delegate.appendToData(this.consumeCharRef() || '&');

var char = this.consume();
if (char === '-' && this.input.charAt(this.index) === '-') {
if (char === '-' && this.peek() === '-') {
this.consume();

@@ -202,2 +203,21 @@ this.transitionTo("commentStart" /* commentStart */);

},
endTagName: function () {
var char = this.consume();
if (isSpace(char)) {
this.transitionTo("beforeAttributeName" /* beforeAttributeName */);
this.tagNameBuffer = '';
}
else if (char === '/') {
this.transitionTo("selfClosingStartTag" /* selfClosingStartTag */);
this.tagNameBuffer = '';
}
else if (char === '>') {
this.delegate.finishTag();
this.transitionTo("beforeData" /* beforeData */);
this.tagNameBuffer = '';
}
else {
this.appendToTagName(char);
}
},
beforeAttributeName: function () {

@@ -411,3 +431,3 @@ var char = this.peek();

if (char === '@' || char === ':' || isAlpha(char)) {
this.transitionTo("tagName" /* tagName */);
this.transitionTo("endTagName" /* endTagName */);
this.tagNameBuffer = '';

@@ -424,2 +444,3 @@ this.delegate.beginEndTag();

this.input = '';
this.tagNameBuffer = '';
this.index = 0;

@@ -500,2 +521,8 @@ this.line = 1;

};
EventedTokenizer.prototype.isIgnoredEndTag = function () {
var tag = this.tagNameBuffer.toLowerCase();
return (tag === 'title' && this.input.substring(this.index, this.index + 8) !== '</title>') ||
(tag === 'style' && this.input.substring(this.index, this.index + 8) !== '</style>') ||
(tag === 'script' && this.input.substring(this.index, this.index + 9) !== '</script>');
};
return EventedTokenizer;

@@ -502,0 +529,0 @@ }());

@@ -23,2 +23,3 @@ import { EntityParser, TokenizerDelegate, TokenizerState } from './types';

private appendToTagName(char);
private isIgnoredEndTag();
states: {

@@ -25,0 +26,0 @@ [k in TokenizerState]?: (this: EventedTokenizer) => void;

@@ -15,2 +15,3 @@ /**

tagName = "tagName",
endTagName = "endTagName",
rcdataLessThanSign = "rcdataLessThanSign",

@@ -17,0 +18,0 @@ rcdataEndTagOpen = "rcdataEndTagOpen",

2

package.json
{
"name": "simple-html-tokenizer",
"version": "0.5.7",
"version": "0.5.8",
"license": "MIT",

@@ -5,0 +5,0 @@ "description": "Simple HTML Tokenizer is a lightweight JavaScript library that can be used to tokenize the kind of HTML normally found in templates.",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc