GithubHelp home page GithubHelp logo

svenslaggare / bbcodeparser Goto Github PK

View Code? Open in Web Editor NEW
35.0 35.0 18.0 67 KB

BB code parser written in TypeScript.

License: MIT License

Shell 0.54% TypeScript 97.88% HTML 1.04% Batchfile 0.54%

bbcodeparser's People

Contributors

accaliadeelementia avatar ndazeo avatar netbull avatar svenslaggare avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

bbcodeparser's Issues

Forgot to publish to npm?

Hi I've noticed that there are some differences between the git repo and npm package.

For example in tokenizer.ts the var attrValueChars have more characters and in NPM they're the same as attrNameChars which breaks my application (I need hash symbols for links).

Can someone republish npm package please? @svenslaggare

Otherwise, I'd be happy to take over this repo if noone's willing to keep working on it.

Registry Key and Hang

Hi,

We came across this as we use this module to render bbCode within our forums.

We noticed that this string in particular hangs:
var parser = new BBCodeParser({}).parseString("[HKEY_LOCAL_MACHINESOFTWAREMicrosoftMicrosoft SDKsSilverlightv4.0AssemblyFoldersEx]");

This is a registry key, so I can definitely see it causing some screwiness somewhere. I thought it would be ignored but it seems to never actually go into the parseString function, it will simply hang in limbo.

Anyway to prevent this?

Thanks!

Is it last version in npm?

Seems that the latest is 1.0.10 from 3 years ago. Stumbled upon the double quotes problem for the attributes that seems to be not updated in npm.

No list functionality for single tags

Nearly all BBCode engines I've used in the past use the following format:

[list]
[*]List item 1
[*]List item 2
[*]List item 3
[/list]

Same as:

<ul>
  <li>List item 1</li>
  <li>List item 2</li>
  <li>List item 3</li>
</ul>

But this is impossible with the parser in its current set up. I can have a look to alter it one day, but I don't know if I'll find the time. Can you help with this?

Error with no valid BB Code parsing

In node.js, I have a error when I typed

> var BBCodeParser = require('bbcode-parser');
undefined
> var parser = new BBCodeParser(BBCodeParser.defaultTags());
undefined
> parser.parseString('[b]Bold text[/b]');
'<b>Bold text</b>'
> parser.parseString('[]Bold text[/b]');
TypeError: Cannot read property 'isValid' of null
    at BBCodeParser.parseString (/tmp/node_modules/bbcode-parser/bbCodeParser.js:50:23)
    at repl:1:8
    at REPLServer.defaultEval (repl.js:132:27)
    at bound (domain.js:254:14)
    at REPLServer.runBound [as eval] (domain.js:267:12)
    at REPLServer.<anonymous> (repl.js:279:12)
    at REPLServer.emit (events.js:107:17)
    at REPLServer.Interface._onLine (readline.js:214:10)
    at REPLServer.Interface._line (readline.js:553:8)
    at REPLServer.Interface._ttyWrite (readline.js:830:14)

I solved it by changing isValid method in bbCodeParserTree.js, like that :

    BBCodeParseTree.prototype.isValid = function () {                                              
        //An tree without subtrees is valid                                                          
        if (this.subTrees.length == 0) {                                                        
            return true;                                                                            
        }                                                                                       
        this.subTrees.forEach( function(value,i){                                          
            var currentTree = value//this.subTrees[i];                                    

            if ( currentTree == null || !currentTree.isValid()) {                                    
                return false;                                                                        
            }                                                                                        
        })                                                                                           

        return true;                                                                                 
    };  

Is this solution the good one ?

How to import it on angular 8?

As always, I import modules in the app.module.ts, but for some reason bbcode-parseq is not displayed as existing for me.

strip bbcode?

Is there anyway to simply strip all bbcode tags from a string?

BBTag is not defined

I am trying to create a custom tag, but am getting BBTag is not defined.

import BBCodeParser from 'bbcode-parser'

let bbTags = {}
bbTags["p"] = new BBTag("p", true, false, false);
const customTagParser = new BBCodeParser(bbTags)

How can I get access to the BBTag constructor in Node?

get length undefined error

Sometimes I pass in undefined or null, I know this is bad, but your script should not die on those errors.

parser.parseString(null, true);

No "" on attributes causes Tree to nullify and invalidate

The Regex match forces Double quotes around token attributes. If any attribute exists without quotes around it the entire tree fails as it doesn't tokenize it properly:

    var attrPattern = new RegExp("(" + attrNameChars + "+)?=\"(" + attrValueChars + "*)\"", "g");

XSS Injection w/ [img] tag in default tags

Due to the URL of [img] tags not being checked, one could type:
[img]test.jpg" onError="alert('hi')[/img]]
Which shows existence of a possible XSS exploit. This is a critical issue in my opinion, and one that should be fixed ASAP.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.