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

xbbcode-parser

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

xbbcode-parser - npm Package Compare versions

Comparing version 0.1.2 to 0.2.0

LICENSE.txt

2

package.json
{
"name": "xbbcode-parser",
"version": "0.1.2",
"version": "0.2.0",
"description": "Allows you to parse BBCode and to extend the markup to add your own tags.",

@@ -5,0 +5,0 @@ "main": "xbbcode.js",

@@ -76,1 +76,5 @@ # Extendible-BBCode-Parser

bugs please let me know.
### Adding 'single' tags
Simply do what you had been doing so far, but without providing an closeTag function.

@@ -86,3 +86,3 @@ /*

*
* LIMITIONS on adding NEW TAGS:
* LIMITATIONS on adding NEW TAGS:
* - Tag names should be alphanumeric (including underscores) and all tags should have an opening tag

@@ -97,2 +97,7 @@ * and a closing tag.

tags = {
'hr': {
openTag: function(params, content) {
return '<hr/>';
}
},
"b": {

@@ -567,3 +572,3 @@ openTag: function(params,content) {

for (var ii = 0; ii < tagList.length; ii++) {
if ( tagList[ii] !== "\\*" ) { // the * tag doesn't have an offical closing tag
if ( tagList[ii] !== "\\*" ) { // the * tag doesn't have an official closing tag
closeTagList.push ( "/" + tagList[ii] );

@@ -663,5 +668,5 @@ }

var processedContent = tags[tagName].noParse ? unprocess(tagContents) : tagContents.replace(bbRegExp, replaceFunct),
openTag = tags[tagName].openTag(tagParams,processedContent),
closeTag = tags[tagName].closeTag(tagParams,processedContent);
openTag = (tags[tagName].openTag) ? tags[tagName].openTag(tagParams,processedContent) : '',
closeTag = (tags[tagName].closeTag) ? tags[tagName].closeTag(tagParams,processedContent) : '';
if ( tags[tagName].displayContent === false) {

@@ -683,3 +688,3 @@ processedContent = "";

tag, we must pre-process the input and add in closing tags [/*] for the star tag.
We have a little levaridge in that we know the text we're processing wont contain the <> characters (they have been
We have a little leverage in that we know the text we're processing wont contain the <> characters (they have been
changed into their HTML entity form to prevent XSS and code injection), so we can use those characters as markers to

@@ -713,2 +718,18 @@ help us define boundaries and figure out where to place the [/*] tags.

function fixSingleTags(text) {
for(var k in tags) {
if(!tags[k].closeTag) {
text = text.replaceAll(`[${k}]`, tags[k].openTag());
}
}
return text;
}
function securityFixes(text) {
return text
.replaceAll("'", '&quot;')
.replaceAll('"', '&apos;')
.replaceAll(';', '&#59;');
}
function addBbcodeLevels(text) {

@@ -756,2 +777,3 @@ while ( text !== (text = text.replace(pbbRegExp, function(matchStr, tagName, tagParams, tagContents) {

config.text = securityFixes(config.text);
config.text = config.text.replace(/\[/g, "&#91;"); // escape ['s that aren't apart of tags

@@ -778,2 +800,4 @@ config.text = config.text.replace(/\]/g, "&#93;"); // escape ['s that aren't apart of tags

ret.html = fixSingleTags(ret.html);
if ( ret.html.indexOf("[") !== -1 || ret.html.indexOf("]") !== -1) {

@@ -780,0 +804,0 @@ errQueue.push("Some tags appear to be misaligned.");

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