Socket
Socket
Sign inDemoInstall

protoblast

Package Overview
Dependencies
Maintainers
1
Versions
102
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

protoblast - npm Package Compare versions

Comparing version 0.7.2 to 0.7.3

5

CHANGELOG.md

@@ -0,1 +1,6 @@

## 0.7.3 (2020-10-08)
* Make `String#tokenizeHTML()` ignore illegal nested custom blocks
* Allow `String#tokenizeHTML()` to ignore blocks that span multiple lines
## 0.7.2 (2020-07-21)

@@ -2,0 +7,0 @@

73

lib/string.js

@@ -661,3 +661,3 @@ module.exports = function BlastString(Blast, Collection, Bound, Obj) {

* @since 0.6.5
* @version 0.7.0
* @version 0.7.3
*

@@ -679,2 +679,3 @@ * @param {String source

block_indexes_arr,
ordered_blocks,
block_indexes,

@@ -690,3 +691,4 @@ prev_state,

key,
i;
i,
j;

@@ -701,7 +703,32 @@ if (options) {

blocks = options.blocks;
ordered_blocks = blocks;
// Ordered blocks are MUCH preferred,
// especially if there is the danger of overlapping open tags
// (Since simple objects do not guarantee an order)
if (Array.isArray(ordered_blocks)) {
blocks = {};
for (i = 0; i < ordered_blocks.length; i++) {
block = ordered_blocks[i];
blocks[block.name] = block;
}
} else {
ordered_blocks = [];
for (key in blocks) {
block = blocks[key];
block.name = key;
ordered_blocks.push(block);
}
}
// Get all indexes in advance, so we don't need to check every char
// to see if it matches a custom block
for (key in blocks) {
open = Bound.String.allIndexesOf(source, blocks[key].open);
// This will probably find MORE indexes than expected,
// because of nested open keys. These will be ignored
for (i = 0; i < ordered_blocks.length; i++) {
block = ordered_blocks[i];
key = block.name;
open = Bound.String.allIndexesOf(source, block.open);

@@ -716,5 +743,27 @@ if (open.length) {

for (i = 0; i < open.length; i++) {
block_indexes[open[i]] = key;
block_indexes_arr.push(open[i]);
for (j = 0; j < open.length; j++) {
// If this already matched another block opener,
// then don't overwrite it
if (block_indexes[open[j]] != null) {
continue;
}
// See if this block is allowed to span multiple lines
if (block.multiline === false) {
end = source.indexOf(block.close, open[j]);
if (end == -1) {
end = source.length - 1;
}
let newline_index = source.slice(open[j], end).indexOf('\n');
if (newline_index > -1) {
continue;
}
}
block_indexes[open[j]] = key;
block_indexes_arr.push(open[j]);
}

@@ -741,5 +790,2 @@ }

// Remove this index from the array
block_indexes_arr.shift();
end = source.indexOf(block.close, i);

@@ -753,2 +799,9 @@

// Remove all block indexes that happen before this end
// (This removes the index that started this block
// + any possible nested blocks, which isn't allowed)
while (block_indexes_arr[0] <= end) {
block_indexes_arr.shift();
}
result.push({

@@ -755,0 +808,0 @@ type : key,

4

package.json
{
"name": "protoblast",
"description": "Native object expansion library",
"version": "0.7.2",
"version": "0.7.3",
"author": "Jelle De Loecker <jelle@elevenways.be>",

@@ -23,3 +23,3 @@ "keywords": [

"coverage" : "nyc --reporter=text --reporter=lcov mocha --exit --timeout 20000 --bail --file test/00-init.js",
"report-coverage" : "nyc report --reporter=lcov && cat ./coverage/lcov.info | codecov"
"report-coverage" : "codecov"
},

@@ -26,0 +26,0 @@ "main": "lib/init.js",

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