zoffixznet / JavaScript-Minifier

JavaScript::Minifier perl module
9 stars 6 forks source link

Corrupt minified script #8

Closed youradds closed 3 years ago

youradds commented 7 years ago

There seems to be a bug with compressing this code:

                if ( ! /^(?:[a-z]+:|#|\?|\.|\/)/.test( href ) && ! emailRegex.test( href ) ) {
                    href = 'http://' + href;
                }

                editor.dom.setAttribs( linkNode, { href: href, 'data-wplink-edit': null } );

It converts to:

if ( ! /^(?:[a-z]+:|#|\?|\.|\/)/.test( href ) && ! emailRegex.test( href ) ) {
                    href = 'http:}
editor.dom.setAttribs(linkNode,{href:href,'data-wplink-edit':null});

I only happened to notice it, as one of the features stopped working in TinyMCE, so I did some digging. I've had to do a work around by using the non-minified version for now, but it'd be good if we could get it fixed :)

Thanks!

zoffixznet commented 7 years ago

This is likely due to Issue #2

faf commented 3 years ago

Actually, that's not related to #2 . This particular issue is both much more specific, and much more complicated.

This is the file in question: https://github.com/WordPress/WordPress/blob/001ffe81fbec4438a9f594f330e18103d21fbcd7/wp-includes/js/tinymce/plugins/wplink/plugin.js

The problem occurs here. But it's caused because of the specific regular expression here. There is an unescaped slash in the first character set which is valid for js implementation of regular expressions, but it's hard to impossible to handle in this minifier (especially keeping in mind it's logic).

Moreover, it's not the only minifier that is unable to properly process the aforementioned file...