Make WordPress Core

Opened 8 years ago

Closed 8 years ago

#38000 closed defect (bug) (fixed)

Visual mode editor is broken after update to 4.6.1

Reported by: arnolem's profile arnolem Owned by: azaozz's profile azaozz
Milestone: 4.7 Priority: normal
Severity: minor Version: 4.6.1
Component: Editor Keywords: has-patch
Focuses: javascript, administration Cc:

Description (last modified by ocean90)

The comment javascript was added in [38349] breaks the javascript code if it is minified :

https://core.trac.wordpress.org/browser/trunk/src/wp-includes/class-wp-editor.php#L1260

See attach for more information.
the patch is attached.

Attachments (3)

js-error.png (61.3 KB) - added by arnolem 8 years ago.
JS Error
js-comment.png (39.8 KB) - added by arnolem 8 years ago.
JS Browser interpretation
38000.patch (502 bytes) - added by arnolem 8 years ago.
38000.patch

Download all attachments as: .zip

Change History (11)

@arnolem
8 years ago

JS Error

@arnolem
8 years ago

JS Browser interpretation

@arnolem
8 years ago

38000.patch

#1 @swissspidy
8 years ago

  • Keywords has-patch added
  • Milestone changed from Awaiting Review to 4.6.2

Good catch, thanks!

I think this should be fixed in 4.6.2.

#2 follow-up: @ocean90
8 years ago

  • Description modified (diff)

@arnolem Welcome to Trac and thanks for your report!

What are you using to minify the HTML in the admin?

#3 in reply to: ↑ 2 ; follow-up: @arnolem
8 years ago

Replying to ocean90:

@arnolem Welcome to Trac and thanks for your report!

What are you using to minify the HTML in the admin?

Thanks !

I have a simple PHP function to minify all HTML elements in function.php
You can see an example here :
http://stackoverflow.com/questions/6225351/how-to-minify-php-page-html-output#answer-6225706

You can rewrite it more simple

<?php
ob_start(function ($buffer) {
    return preg_replace([
        '/\>[^\S ]+/s',  // strip whitespaces after tags, except space
        '/[^\S ]+\</s',  // strip whitespaces before tags, except space
        '/(\s)+/s'       // shorten multiple whitespace sequences
    ], ['>','<','\\1'], $buffer);
});

#4 in reply to: ↑ 3 @azaozz
8 years ago

Replying to arnolem:

I have a simple PHP function to minify all HTML elements in function.php

I'm afraid this preg_replace() is not "up for the job". As mentioned in the comments at the link you posted, it will potentially break anything in a <script>, <pre> and <textarea> tags. There are probably better "HTML white space removers" you could use.

Of course we will fix the comment style in this inline JS, but you will probably run into more problems in the future.

#5 @swissspidy
8 years ago

  • Milestone changed from 4.6.2 to 4.7
  • Severity changed from normal to minor

Might as well be a wontfix, but changing the milestone as there's a patch for changing the comment.

#6 @swissspidy
8 years ago

@azaozz What's your opinion on this? Leaning towards wontfix, but on the other hand it would be such a minor change.

#7 @azaozz
8 years ago

Actually this inline JS will be removed in 4.7 as the fix for RTL is included in the latest TinyMCE version. We can close it after updating TinyMCE.

#8 @azaozz
8 years ago

  • Owner set to azaozz
  • Resolution set to fixed
  • Status changed from new to closed
Note: See TracTickets for help on using tickets.