patorjk / Extendible-BBCode-Parser

Allows you to parse BBCode and to extend the markup to add your own tags. All major tags are supported and parser reports back any errors it finds.
http://patorjk.com/bbcode-previewer/
MIT License
133 stars 54 forks source link

Introduces additional '#59' when transforming HTML tags #32

Open MichaelKaaden opened 1 year ago

MichaelKaaden commented 1 year ago

xbbcode-parse@0.2.1 seems to get HTML tags wrong.

Taking <h1>Hello World!</h1> as input, it produces &lt&#59;h1&gt&#59;Hello World!&lt&#59;/h1&gt&#59;.

I had expected &lt;h1&gt;Hello World!&lt;/h1&gt;

Reproduction:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <link rel="stylesheet" type="text/css" href="xbbcode.css">
    <title>Example</title>
</head>
<body>
<script src="xbbcode.js"></script>
<script>
    var result = XBBCODE.process({
        text: "<h1>Hello World!</h1>",
    });
    console.error("Errors", result.error);
    console.dir(result.errorQueue);
    console.log(result.html);
</script>
</body>
</html>
MichaelKaaden commented 1 year ago

Should be fixed with PR 31.

DetlefPeters commented 1 year ago

Sorry but this issue is not fixed with 0.2.2. The "security fixes" leave unwanted #&59; in the resulting string! return text .replaceAll("'", ''') .replaceAll('"', '"') .replaceAll(';', ';'); should better be return text .replaceAll(';', ';') .replaceAll("'", ''') .replaceAll('"', '"'); so that the semicolons which are inserted in the other lines on purpose are not replaced again