Socket
Socket
Sign inDemoInstall

shortcode-tree

Package Overview
Dependencies
Maintainers
1
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

shortcode-tree - npm Package Compare versions

Comparing version 1.4.2 to 1.4.3

10

dist/shortcode-parser.js

@@ -58,2 +58,10 @@ "use strict";

var predictedAsSelfClosing = input.indexOf(closingTagExpected) === -1;
if (predictedAsSelfClosing) {
shortcode.isSelfClosing = true;
} else {
shortcode.isSelfClosing = false;
}
if (shortcode.isSelfClosing && input.substr(openBlockTextFull.length, closingTagExpected.length) === closingTagExpected) {

@@ -67,2 +75,4 @@ // Special case: misbehaving little bugger claims to be improperly self-closing, but decided to close itself

shortcode.codeText = input.substr(openBlockStartIdx, input.length - offsetFromEnd);
shortcode.isSelfClosing = false;
} else if (options.precise && !shortcode.isSelfClosing) {

@@ -69,0 +79,0 @@ var stackLevel = 0;

2

package.json
{
"name": "shortcode-tree",
"version": "1.4.2",
"version": "1.4.3",
"description": "Parser library for reading short codes (BB codes) into a tree structure",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

@@ -113,8 +113,9 @@ let ShortcodeParser = require('../src').ShortcodeParser;

it('throws an error for malformatted input: invalid closing tag', function () {
it('does not error / performs best guess for malformatted input: invalid/missing closing tag', function () {
let testInput = `we [open] but no [/close]`;
expect(function () {
ShortcodeParser.parseShortcode(testInput, options)
}).to.throw("closing tag");
let expectedOutput = new Shortcode("open", null, {}, true, "[open]", 3);
let actualOutput = ShortcodeParser.parseShortcode(testInput, options) || null;
expect(actualOutput).to.deep.equal(expectedOutput);
});

@@ -171,3 +172,3 @@

it('does not throw errors if "throwErrors" is set to false', function () {
let testInput = "this might be [b]invalid";
let testInput = "this might be [invalid";
let expectedOutput = false;

@@ -189,3 +190,3 @@ let actualOutput = ShortcodeParser.parseShortcode(testInput, { throwErrors: false });

let testInput = `[img src="what.jpg" standards="no"][/img] asdf`;
let expectedOutput = new Shortcode('img', "", {"src": "what.jpg", "standards": "no"}, true, `[img src="what.jpg" standards="no"][/img]`, 0);
let expectedOutput = new Shortcode('img', "", {"src": "what.jpg", "standards": "no"}, false, `[img src="what.jpg" standards="no"][/img]`, 0);
let actualOutput = ShortcodeParser.parseShortcode(testInput, { selfClosingTags: ["img"] }) || null;

@@ -192,0 +193,0 @@

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