JiLiZART / BBob

⚡️Blazing fast js bbcode parser, that transforms and parses bbcode to AST and transform it to HTML, React, Vue with plugin support in pure javascript, no dependencies
https://codepen.io/JiLiZART/full/vzMvpd
MIT License
166 stars 19 forks source link

onlyAllowTags doesn't support case insensitive tags #190

Closed Rhababo closed 1 year ago

Rhababo commented 1 year ago

The allowed tags settings doesn't have an option for checking for case sensitivity.

One option to fix this is to add a .toLowerCase() to the isAllowedTag() function in the parser

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

    return true;
  };

toTagNode() already contains a .toLowerCase() statement

toTagNode() {
return new TagNode(this.tag.toLowerCase(), this.attrs, this.content);
}

so all tags get converted to lowercase anyway.

Could we either add .toLowerCase() to the isAllowedTag function, or, if we want block incorrectly cased tags, can we add an option that when flagged allows for case insensitive tags?

JiLiZART commented 1 year ago

bbcode like an a html is ignoring case of tags, so i think the parser andonlyAllowTags also should ignore the case of tags. I fix this behavior in next release.

Mondrethos commented 1 year ago

bbcode like an a html is ignoring case of tags, so i think the parser andonlyAllowTags also should ignore the case of tags. I fix this behavior in next release.

Thanks! Pretty excited for this fix.

JiLiZART commented 1 year ago

Fixed in 3.0.2