froala / angular-froala

Angular.js bindings for Froala WYSIWYG HTML Rich Text Editor.
https://froala.com/wysiwyg-editor
MIT License
306 stars 123 forks source link

angular.lowercase replacement error #189

Closed atakdale closed 6 years ago

atakdale commented 6 years ago

The replacement of angular.lowercase() with String toLowerCase() in froala-sanitize.js is causing errors. The example would be line 333 where the parseEndTag(); is called.

The parseEndTag() definition looks like this:

function parseEndTag(tag, tagName) {
    var pos = 0, i;
    tagName = tagName.toLowerCase();
    if (tagName) {
        // Find the closest opened tag of the same type
        for (pos = stack.length - 1; pos >= 0; pos--) {
            if (stack[pos] === tagName) {
                break;
            }
        }
    }
...

When the parseEndTag() on line 333 is called without any parameters, the tagName.toLowerCase(); call results in an error since the tagName is undefined.

On the other hand, the old definition tagName = angular.lowercase(tagName); didn't cause any errors if the tagName was undefined.

I haven't checked other places with the replacement so I am not sure that's the only place where it happens.

haydar100 commented 6 years ago

Got the same problem (Version 2.8.5). I just moved the tagName = tagName.toLowerCase(); expression inside the if statement. Hopefully a new release will solve this problem 👍