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

@bbob/parser

Package Overview
Dependencies
Maintainers
1
Versions
62
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@bbob/parser - npm Package Compare versions

Comparing version 3.0.1 to 3.0.2

5

dist/index.js

@@ -559,2 +559,3 @@ (function (global, factory) {

const closeTag = options.closeTag || pluginHelper.CLOSE_BRAKET;
const onlyAllowTags = (options.onlyAllowTags || []).filter(Boolean).map((tag)=>tag.toLowerCase());
let tokenizer = null;

@@ -606,4 +607,4 @@ /**

*/ const isAllowedTag = (value)=>{
if (options.onlyAllowTags && options.onlyAllowTags.length) {
return options.onlyAllowTags.indexOf(value) >= 0;
if (onlyAllowTags.length) {
return onlyAllowTags.indexOf(value.toLowerCase()) >= 0;
}

@@ -610,0 +611,0 @@ return true;

2

dist/index.min.js

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

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@bbob/plugin-helper")):"function"==typeof define&&define.amd?define(["exports","@bbob/plugin-helper"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).BbobParser={},e.pluginHelper)}(this,function(e,t){"use strict";let r="type",n="value",s="line",i=e=>e&&void 0!==e[n]?e[n]:"",l=e=>e&&e[s]||0,a=e=>e&&e.row||0,u=e=>!!e&&void 0!==e[r]&&(5===e[r]||6===e[r]||1===e[r]),o=e=>!!e&&void 0!==e[r]&&2===e[r],g=e=>i(e).charCodeAt(0)===t.SLASH.charCodeAt(0),h=e=>!g(e),f=e=>!!e&&void 0!==e[r]&&3===e[r],p=e=>!!e&&void 0!==e[r]&&4===e[r],A=e=>{let t=i(e);return g(e)?t.slice(1):t},c=e=>(t.OPEN_BRAKET,i(e)+t.CLOSE_BRAKET);class d{isEmpty(){return isNaN(this[r])}isText(){return u(this)}isTag(){return o(this)}isAttrName(){return f(this)}isAttrValue(){return p(this)}isStart(){return h(this)}isEnd(){return g(this)}getName(){return A(this)}getValue(){return i(this)}getLine(){return l(this)}getColumn(){return a(this)}toString(){return c(this)}constructor(e,t,i,l){this[r]=Number(e),this[n]=String(t),this[s]=Number(i),this.row=Number(l)}}function T(e,t){let r={pos:0,len:e.length},n=t=>{let{pos:n}=r,s=e.indexOf(t,n);return s>=0?e.substring(n,s):""},s=t=>e.indexOf(t,r.pos)>=0,i=()=>r.len>r.pos,l=(e=1,n)=>{r.pos+=e,t&&t.onSkip&&!n&&t.onSkip()},a=()=>e.substring(r.pos),u=(t=0)=>e.substring(r.pos,r.pos+t),o=()=>e[r.pos],g=()=>{let t=r.pos-1;return void 0!==e[t]?e[t]:null},h=()=>{let t=r.pos+1;return t<=e.length-1?e[t]:null},f=(t,n)=>{let s=0;if(i())for(s=r.pos;i()&&t(o());)l(1,n);return e.substring(s,r.pos)};this.skip=l,this.hasNext=i,this.getCurr=o,this.getRest=a,this.getNext=h,this.getPrev=g,this.isLast=()=>r.pos===r.len,this.includes=s,this.grabWhile=f,this.grabN=u,this.substrUntilChar=n}let b=(e,t)=>new T(e,t),E=(e,t)=>{for(;e.charAt(0)===t;)e=e.substring(1);for(;e.charAt(e.length-1)===t;)e=e.substring(0,e.length-1);return e},S=e=>e.replace(t.BACKSLASH+t.QUOTEMARK,t.QUOTEMARK);function N(e=[]){let t=()=>Array.isArray(e)&&e.length>0&&void 0!==e[e.length-1]?e[e.length-1]:null,r=()=>!!e.length&&e.pop(),n=t=>e.push(t);this.push=n,this.toArray=()=>e,this.getLast=t,this.flushLast=r}let L=(e=[])=>new N(e),C=(e,t,r=0,n=0)=>new d(e,t,r,n);function x(e,r={}){let n=0,s=0,i=-1,l=0,a=0,u="",o=Array(Math.floor(e.length)),g=r.openTag||t.OPEN_BRAKET,h=r.closeTag||t.CLOSE_BRAKET,f=!!r.enableEscapeTags,p=r.contextFreeTags||[],A=r.onToken||(()=>{}),c=[h,g,t.QUOTEMARK,t.BACKSLASH,t.SPACE,t.TAB,t.EQ,t.N,"!"],d=[g,t.SPACE,t.TAB,t.N],T=[t.SPACE,t.TAB],N=[t.EQ,t.SPACE,t.TAB],L=e=>c.indexOf(e)>=0,x=e=>e===t.N,y=e=>T.indexOf(e)>=0,k=e=>-1===d.indexOf(e),O=e=>N.indexOf(e)>=0,m=e=>e===g||e===h||e===t.BACKSLASH,B=e=>e===t.BACKSLASH,K=()=>{s++},P=e=>S(E(e,t.QUOTEMARK)),Q=(e,t)=>{""!==u&&t&&(u=""),""===u&&p.includes(e)&&(u=e)},w=b(e,{onSkip:K});function R(e,t){let r=C(e,t,n,s);A(r),o[i+=1]=r}return{tokenize:function(){for(l=0;w.hasNext();)switch(l){case 1:l=function(){let e=w.getCurr(),r=w.getNext();w.skip();let n=w.substrUntilChar(h),s=0===n.length||n.indexOf(g)>=0;if(L(r)||s||w.isLast())return R(1,e),0;let i=-1===n.indexOf(t.EQ),l=n[0]===t.SLASH;if(i||l){let a=w.grabWhile(e=>e!==h);return w.skip(),R(2,a),Q(a,l),0}return 2}();break;case 2:l=function(){let e=w.grabWhile(e=>e!==h,!0),r=b(e,{onSkip:K}),n=r.includes(t.SPACE);for(a=0;r.hasNext();)a=function(e,r){if(1===a){let n=e=>!(e===t.EQ||y(e)),s=e.grabWhile(n),i=e.isLast(),l=e.getCurr()!==t.EQ;return(e.skip(),i||l?R(4,P(s)):R(3,s),i)?0:l?1:2}if(2===a){let u=!1,o=n=>{let s=n===t.QUOTEMARK,i=e.getPrev(),l=e.getNext(),a=i===t.BACKSLASH,o=l===t.EQ,g=y(n),h=y(l);return!!(u&&O(n))||(!s||!!a||!!(u=!u)||!!o||!!h)&&(!!r||!1===g)},g=e.grabWhile(o);return(e.skip(),R(4,P(g)),e.isLast())?0:1}let h=r=>!(r===t.EQ||y(r)||e.isLast()),f=e.grabWhile(h);if(R(2,f),Q(f),e.skip(),r)return 2;let p=e.includes(t.EQ);return p?1:2}(r,!n);return w.skip(),0}();break;default:l=function(){if(x(w.getCurr()))return R(6,w.getCurr()),w.skip(),s=0,n++,0;if(y(w.getCurr())){let e=w.grabWhile(y);return R(5,e),0}if(w.getCurr()===g){if(u){let r=g.length+t.SLASH.length+u.length,i=`${g}${t.SLASH}${u}`,l=w.grabN(r);if(l===i)return 1}else if(w.includes(h))return 1;return R(1,w.getCurr()),w.skip(),0}if(f){if(B(w.getCurr())){let a=w.getCurr(),o=w.getNext();return(w.skip(),m(o))?(w.skip(),R(1,o),0):(R(1,a),0)}let p=e=>k(e)&&!B(e),A=w.grabWhile(p);return R(1,A),0}let c=w.grabWhile(k);return R(1,c),0}()}return o.length=i+1,o},isTokenNested:function(r){let n=g+t.SLASH+r.getValue();return e.indexOf(n)>-1}}}let y=(e,r={})=>{let n=r.openTag||t.OPEN_BRAKET,s=r.closeTag||t.CLOSE_BRAKET,i=null,l=L(),a=L(),u=L(),o=L(),g=new Set,h=e=>{let t=e.getValue();return!g.has(t)&&i.isTokenNested&&i.isTokenNested(e)?(g.add(t),!0):g.has(t)},f=e=>Boolean(g.has(e)),p=e=>!r.onlyAllowTags||!r.onlyAllowTags.length||r.onlyAllowTags.indexOf(e)>=0,A=()=>{u.flushLast()&&o.flushLast()},c=()=>{let e=a.getLast();return e&&Array.isArray(e.content)?e.content:l.toArray()},d=(e,t=!0)=>{let r=c();Array.isArray(r)&&(r.push(e.toTagStart({openTag:n,closeTag:s})),e.content.length&&(e.content.forEach(e=>{r.push(e)}),t&&r.push(e.toTagEnd({openTag:n,closeTag:s}))))},T=e=>{let r=c();Array.isArray(r)&&(t.isTagNode(e)?p(e.tag)?r.push(e.toTagNode()):d(e):r.push(e))},b=e=>{A();let r=t.TagNode.create(e.getValue()),n=h(e);u.push(r),n?a.push(r):T(r)},E=e=>{A();let t=a.flushLast();if(t)T(t);else if("function"==typeof r.onError){let n=e.getValue(),s=e.getLine(),i=e.getColumn();r.onError({message:`Inconsistent tag '${n}' on line ${s} and column ${i}`,tagName:n,lineNumber:s,columnNumber:i})}},S=e=>{e.isStart()&&b(e),e.isEnd()&&E(e)},N=e=>{let t=u.getLast(),r=e.getValue(),n=f(e);if(t){if(e.isAttrName())o.push(r),t.attr(o.getLast(),"");else if(e.isAttrValue()){let s=o.getLast();s?(t.attr(s,r),o.flushLast()):t.attr(r,r)}else e.isText()?n?t.append(r):T(r):e.isTag()&&T(e.toString())}else e.isText()?T(r):e.isTag()&&T(e.toString())},C=e=>{e.isTag()?S(e):N(e)};(i=(r.createTokenizer?r.createTokenizer:x)(e,{onToken:C,openTag:n,closeTag:s,onlyAllowTags:r.onlyAllowTags,contextFreeTags:r.contextFreeTags,enableEscapeTags:r.enableEscapeTags})).tokenize();let y=a.flushLast();return y&&f(y.tag)&&d(y,!1),l.toArray()};Object.defineProperty(e,"TagNode",{enumerable:!0,get:function(){return t.TagNode}}),e.default=y,e.parse=y,Object.defineProperty(e,"__esModule",{value:!0})});
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@bbob/plugin-helper")):"function"==typeof define&&define.amd?define(["exports","@bbob/plugin-helper"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).BbobParser={},e.pluginHelper)}(this,function(e,t){"use strict";let r="type",n="value",s="line",i=e=>e&&void 0!==e[n]?e[n]:"",l=e=>e&&e[s]||0,a=e=>e&&e.row||0,u=e=>!!e&&void 0!==e[r]&&(5===e[r]||6===e[r]||1===e[r]),o=e=>!!e&&void 0!==e[r]&&2===e[r],g=e=>i(e).charCodeAt(0)===t.SLASH.charCodeAt(0),h=e=>!g(e),f=e=>!!e&&void 0!==e[r]&&3===e[r],p=e=>!!e&&void 0!==e[r]&&4===e[r],A=e=>{let t=i(e);return g(e)?t.slice(1):t},c=e=>(t.OPEN_BRAKET,i(e)+t.CLOSE_BRAKET);class d{isEmpty(){return isNaN(this[r])}isText(){return u(this)}isTag(){return o(this)}isAttrName(){return f(this)}isAttrValue(){return p(this)}isStart(){return h(this)}isEnd(){return g(this)}getName(){return A(this)}getValue(){return i(this)}getLine(){return l(this)}getColumn(){return a(this)}toString(){return c(this)}constructor(e,t,i,l){this[r]=Number(e),this[n]=String(t),this[s]=Number(i),this.row=Number(l)}}function T(e,t){let r={pos:0,len:e.length},n=t=>{let{pos:n}=r,s=e.indexOf(t,n);return s>=0?e.substring(n,s):""},s=t=>e.indexOf(t,r.pos)>=0,i=()=>r.len>r.pos,l=(e=1,n)=>{r.pos+=e,t&&t.onSkip&&!n&&t.onSkip()},a=()=>e.substring(r.pos),u=(t=0)=>e.substring(r.pos,r.pos+t),o=()=>e[r.pos],g=()=>{let t=r.pos-1;return void 0!==e[t]?e[t]:null},h=()=>{let t=r.pos+1;return t<=e.length-1?e[t]:null},f=(t,n)=>{let s=0;if(i())for(s=r.pos;i()&&t(o());)l(1,n);return e.substring(s,r.pos)};this.skip=l,this.hasNext=i,this.getCurr=o,this.getRest=a,this.getNext=h,this.getPrev=g,this.isLast=()=>r.pos===r.len,this.includes=s,this.grabWhile=f,this.grabN=u,this.substrUntilChar=n}let b=(e,t)=>new T(e,t),E=(e,t)=>{for(;e.charAt(0)===t;)e=e.substring(1);for(;e.charAt(e.length-1)===t;)e=e.substring(0,e.length-1);return e},S=e=>e.replace(t.BACKSLASH+t.QUOTEMARK,t.QUOTEMARK);function N(e=[]){let t=()=>Array.isArray(e)&&e.length>0&&void 0!==e[e.length-1]?e[e.length-1]:null,r=()=>!!e.length&&e.pop(),n=t=>e.push(t);this.push=n,this.toArray=()=>e,this.getLast=t,this.flushLast=r}let L=(e=[])=>new N(e),C=(e,t,r=0,n=0)=>new d(e,t,r,n);function x(e,r={}){let n=0,s=0,i=-1,l=0,a=0,u="",o=Array(Math.floor(e.length)),g=r.openTag||t.OPEN_BRAKET,h=r.closeTag||t.CLOSE_BRAKET,f=!!r.enableEscapeTags,p=r.contextFreeTags||[],A=r.onToken||(()=>{}),c=[h,g,t.QUOTEMARK,t.BACKSLASH,t.SPACE,t.TAB,t.EQ,t.N,"!"],d=[g,t.SPACE,t.TAB,t.N],T=[t.SPACE,t.TAB],N=[t.EQ,t.SPACE,t.TAB],L=e=>c.indexOf(e)>=0,x=e=>e===t.N,y=e=>T.indexOf(e)>=0,k=e=>-1===d.indexOf(e),O=e=>N.indexOf(e)>=0,m=e=>e===g||e===h||e===t.BACKSLASH,B=e=>e===t.BACKSLASH,K=()=>{s++},P=e=>S(E(e,t.QUOTEMARK)),Q=(e,t)=>{""!==u&&t&&(u=""),""===u&&p.includes(e)&&(u=e)},w=b(e,{onSkip:K});function R(e,t){let r=C(e,t,n,s);A(r),o[i+=1]=r}return{tokenize:function(){for(l=0;w.hasNext();)switch(l){case 1:l=function(){let e=w.getCurr(),r=w.getNext();w.skip();let n=w.substrUntilChar(h),s=0===n.length||n.indexOf(g)>=0;if(L(r)||s||w.isLast())return R(1,e),0;let i=-1===n.indexOf(t.EQ),l=n[0]===t.SLASH;if(i||l){let a=w.grabWhile(e=>e!==h);return w.skip(),R(2,a),Q(a,l),0}return 2}();break;case 2:l=function(){let e=w.grabWhile(e=>e!==h,!0),r=b(e,{onSkip:K}),n=r.includes(t.SPACE);for(a=0;r.hasNext();)a=function(e,r){if(1===a){let n=e=>!(e===t.EQ||y(e)),s=e.grabWhile(n),i=e.isLast(),l=e.getCurr()!==t.EQ;return(e.skip(),i||l?R(4,P(s)):R(3,s),i)?0:l?1:2}if(2===a){let u=!1,o=n=>{let s=n===t.QUOTEMARK,i=e.getPrev(),l=e.getNext(),a=i===t.BACKSLASH,o=l===t.EQ,g=y(n),h=y(l);return!!(u&&O(n))||(!s||!!a||!!(u=!u)||!!o||!!h)&&(!!r||!1===g)},g=e.grabWhile(o);return(e.skip(),R(4,P(g)),e.isLast())?0:1}let h=r=>!(r===t.EQ||y(r)||e.isLast()),f=e.grabWhile(h);if(R(2,f),Q(f),e.skip(),r)return 2;let p=e.includes(t.EQ);return p?1:2}(r,!n);return w.skip(),0}();break;default:l=function(){if(x(w.getCurr()))return R(6,w.getCurr()),w.skip(),s=0,n++,0;if(y(w.getCurr())){let e=w.grabWhile(y);return R(5,e),0}if(w.getCurr()===g){if(u){let r=g.length+t.SLASH.length+u.length,i=`${g}${t.SLASH}${u}`,l=w.grabN(r);if(l===i)return 1}else if(w.includes(h))return 1;return R(1,w.getCurr()),w.skip(),0}if(f){if(B(w.getCurr())){let a=w.getCurr(),o=w.getNext();return(w.skip(),m(o))?(w.skip(),R(1,o),0):(R(1,a),0)}let p=e=>k(e)&&!B(e),A=w.grabWhile(p);return R(1,A),0}let c=w.grabWhile(k);return R(1,c),0}()}return o.length=i+1,o},isTokenNested:function(r){let n=g+t.SLASH+r.getValue();return e.indexOf(n)>-1}}}let y=(e,r={})=>{let n=r.openTag||t.OPEN_BRAKET,s=r.closeTag||t.CLOSE_BRAKET,i=(r.onlyAllowTags||[]).filter(Boolean).map(e=>e.toLowerCase()),l=null,a=L(),u=L(),o=L(),g=L(),h=new Set,f=e=>{let t=e.getValue();return!h.has(t)&&l.isTokenNested&&l.isTokenNested(e)?(h.add(t),!0):h.has(t)},p=e=>Boolean(h.has(e)),A=e=>!i.length||i.indexOf(e.toLowerCase())>=0,c=()=>{o.flushLast()&&g.flushLast()},d=()=>{let e=u.getLast();return e&&Array.isArray(e.content)?e.content:a.toArray()},T=(e,t=!0)=>{let r=d();Array.isArray(r)&&(r.push(e.toTagStart({openTag:n,closeTag:s})),e.content.length&&(e.content.forEach(e=>{r.push(e)}),t&&r.push(e.toTagEnd({openTag:n,closeTag:s}))))},b=e=>{let r=d();Array.isArray(r)&&(t.isTagNode(e)?A(e.tag)?r.push(e.toTagNode()):T(e):r.push(e))},E=e=>{c();let r=t.TagNode.create(e.getValue()),n=f(e);o.push(r),n?u.push(r):b(r)},S=e=>{c();let t=u.flushLast();if(t)b(t);else if("function"==typeof r.onError){let n=e.getValue(),s=e.getLine(),i=e.getColumn();r.onError({message:`Inconsistent tag '${n}' on line ${s} and column ${i}`,tagName:n,lineNumber:s,columnNumber:i})}},N=e=>{e.isStart()&&E(e),e.isEnd()&&S(e)},C=e=>{let t=o.getLast(),r=e.getValue(),n=p(e);if(t){if(e.isAttrName())g.push(r),t.attr(g.getLast(),"");else if(e.isAttrValue()){let s=g.getLast();s?(t.attr(s,r),g.flushLast()):t.attr(r,r)}else e.isText()?n?t.append(r):b(r):e.isTag()&&b(e.toString())}else e.isText()?b(r):e.isTag()&&b(e.toString())},y=e=>{e.isTag()?N(e):C(e)};(l=(r.createTokenizer?r.createTokenizer:x)(e,{onToken:y,openTag:n,closeTag:s,onlyAllowTags:r.onlyAllowTags,contextFreeTags:r.contextFreeTags,enableEscapeTags:r.enableEscapeTags})).tokenize();let k=u.flushLast();return k&&p(k.tag)&&T(k,!1),a.toArray()};Object.defineProperty(e,"TagNode",{enumerable:!0,get:function(){return t.TagNode}}),e.default=y,e.parse=y,Object.defineProperty(e,"__esModule",{value:!0})});

@@ -19,2 +19,3 @@ import { TagNode, CLOSE_BRAKET, OPEN_BRAKET, isTagNode } from '@bbob/plugin-helper';

const closeTag = options.closeTag || CLOSE_BRAKET;
const onlyAllowTags = (options.onlyAllowTags || []).filter(Boolean).map((tag)=>tag.toLowerCase());
let tokenizer = null;

@@ -66,4 +67,4 @@ /**

*/ const isAllowedTag = (value)=>{
if (options.onlyAllowTags && options.onlyAllowTags.length) {
return options.onlyAllowTags.indexOf(value) >= 0;
if (onlyAllowTags.length) {
return onlyAllowTags.indexOf(value.toLowerCase()) >= 0;
}

@@ -70,0 +71,0 @@ return true;

@@ -38,2 +38,5 @@ "use strict";

var closeTag = options.closeTag || _pluginHelper.CLOSE_BRAKET;
var onlyAllowTags = (options.onlyAllowTags || []).filter(Boolean).map(function(tag) {
return tag.toLowerCase();
});
var tokenizer = null;

@@ -87,4 +90,4 @@ /**

*/ var isAllowedTag = function(value) {
if (options.onlyAllowTags && options.onlyAllowTags.length) {
return options.onlyAllowTags.indexOf(value) >= 0;
if (onlyAllowTags.length) {
return onlyAllowTags.indexOf(value.toLowerCase()) >= 0;
}

@@ -91,0 +94,0 @@ return true;

{
"name": "@bbob/parser",
"version": "3.0.1",
"version": "3.0.2",
"description": "A BBCode to AST Parser part of @bbob",

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

"dependencies": {
"@bbob/plugin-helper": "^3.0.0"
"@bbob/plugin-helper": "^3.0.2"
},

@@ -19,0 +19,0 @@ "main": "lib/index.js",

@@ -23,2 +23,5 @@ import {

const closeTag = options.closeTag || CLOSE_BRAKET;
const onlyAllowTags = (options.onlyAllowTags || [])
.filter(Boolean)
.map((tag) => tag.toLowerCase());

@@ -87,4 +90,4 @@ let tokenizer = null;

const isAllowedTag = (value) => {
if (options.onlyAllowTags && options.onlyAllowTags.length) {
return options.onlyAllowTags.indexOf(value) >= 0;
if (onlyAllowTags.length) {
return onlyAllowTags.indexOf(value.toLowerCase()) >= 0;
}

@@ -91,0 +94,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