• Resolved levymetal

    (@levymetal)


    Hey Frank,

    This is a bit of an obscure issue, but I’ve noticed that Autoptimize removes backslashes from HTML comments, even if HTML minification is completely disabled.

    We put a bit of ascii art in the header of all websites we build. I noticed that the ascii art was broken, which led me to find out Autoptimize is the cause.

    Also, the “Keep HTML comments?” setting still messes with the comments a bit – some newlines are getting removed. Other’s aren’t. I can’t figure out why.

    Any ideas on how I can resolve this?

    https://www.ads-software.com/plugins/autoptimize/

Viewing 15 replies - 1 through 15 (of 15 total)
  • Plugin Author Frank Goossens

    (@futtta)

    ascii art, that’s obscure (but cool) allright ??

    put the entire block between noptimize-tags (see FAQ) and all should be fine?

    frank

    Thread Starter levymetal

    (@levymetal)

    Thanks for the response Frank!

    I tried noptimize, but it’s still removing some newlines, and it’s still removing backslashes.

    For example, view the source of https://loveandmoney.agency. The ascii art is wrapped in noptimize tags.

    This is what’s in the template: https://gist.github.com/levymetal/b01ecd493db68076c6fe

    I’d love to get this working!

    Plugin Author Frank Goossens

    (@futtta)

    ah, small mistake in how you implemneted noptimize actually, should be;

    <!--noptimize-->
    This site was made with
    
     /$$        /$$$$$$  /$$    /$$ /$$$$$$$$        /$$$           /$$      /$$  /$$$$$$  /$$   /$$ /$$$$$$$$ /$$     /$$
    | $$       /$$__  $$| $$   | $$| $$_____/       /$$ $$         | $$$    /$$$ /$$__  $$| $$$ | $$| $$_____/|  $$   /$$/
    | $$      | $$  \ $$| $$   | $$| $$            |  $$$          | $$$$  /$$$$| $$  \ $$| $$$$| $$| $$       \  $$ /$$/
    | $$      | $$  | $$|  $$ / $$/| $$$$$          /$$ $$/$$      | $$ $$/$$ $$| $$  | $$| $$ $$ $$| $$$$$     \  $$$$/
    | $$      | $$  | $$ \  $$ $$/ | $$__/         | $$  $$_/      | $$  $$$| $$| $$  | $$| $$  $$$$| $$__/      \  $$/
    | $$      | $$  | $$  \  $$$/  | $$            | $$\  $$       | $$\  $ | $$| $$  | $$| $$\  $$$| $$          | $$
    | $$$$$$$$|  $$$$$$/   \  $/   | $$$$$$$$      |  $$$$/$$      | $$ \/  | $$|  $$$$$$/| $$ \  $$| $$$$$$$$    | $$
    |________/ \______/     \_/    |________/       \____/\_/      |__/     |__/ \______/ |__/  \__/|________/    |__/    
    
                                                                                            https://loveandmoney.agency
    <!--/noptimize-->

    can you give that a shot? ??

    frank

    This isn’t that obscure of an issue. I’m running into exactly the same thing today with ASCII art. Backslashes are being removed for me even if the whole block is inside of “noptimize” tags, as specified above.

    Plugin Author Frank Goossens

    (@futtta)

    can you give me a URL so I can have a look Stephen?

    frank

    Sure. Here’s the source of my page head:

    https://gist.github.com/stephenjbell/808f38052cde24f53d3b

    Here’s how it looks when “Optimize HTML code?” is checked in Autoptimize:

    https://gist.github.com/stephenjbell/5d9392b70bd83b41337a

    Plugin Author Frank Goossens

    (@futtta)

    OK, I identified the problem; restore_noptimize() on line 100 of autoptimizeBase.php does a stripslashes on the base64decoded string;

    'return stripslashes(base64_decode($matches[1]));'

    replace that with:

    'return base64_decode($matches[1]);'

    and the ascii-art will be OK.

    now the problem: I’m pretty sure I added the stripslashes for some reason, but can’t remember why really *puzzled*

    frank

    Thanks! I love your plugin and appreciate you taking the time to find a fix.

    Plugin Author Frank Goossens

    (@futtta)

    If you guys can confirm noptimize works OK even without the stripslashes, then I might even be inclined to remove it from my code as well ??

    frank

    Plugin Author Frank Goossens

    (@futtta)

    OK, I’ve been able to trace the reason for the stripslashes down to a change in AO 1.5 (just after I took over from the original author), cfr. https://plugins.svn.www.ads-software.com/autoptimize/tags/1.5/classes/autoptimizeStyles.php, which has;

    //Restore IE hacks
    	// fgo: added stripslashes as e modifier escapes stuff
    	$this->content = preg_replace('#%%IEHACK%%(.*)%%IEHACK%%#Usie','stripslashes(base64_decode("$1"))',$this->content);

    and as the IEHACK-code was the basis for noptimize, I somewhat blindly copied the stripslashes. Taking into account that I’ve since switched from preg_replace with e-modifier to preg_replace_callback which does not do an addslashes encoding, there’s no need for stripslashes any more.

    so to cut a long story short; in the next release of AO stripslashes will be removed from all “hiding” functions in autoptimizeBase.php, including the noptimize-one.

    frank

    Replacing that line in autoptimizeBase.php has corrected the problem, and doesn’t seem to have had any negative effects. Thanks again.

    Plugin Author Frank Goossens

    (@futtta)

    OK, modified this in the Github-version, cfr. commit https://github.com/futtta/autoptimize/commit/1ddc83585dc1099a2fa6a114f679b50d5f8a4969

    thanks for reporting & assisting!
    frank

    Thread Starter levymetal

    (@levymetal)

    Confirmed working for me as well. Thanks mate!

    Ah I remember the days of stripslashes.

    I placed a script tag with some json inside a nooptimize tag and it really can screw up your website something bad. Removing backslashes from json code can cause html parsing errors if the json itself contains html strings.

    I removed that stripslashes and it seems to be working. When is the next release?

    Thanks for finding this Frank. Saved me hours probably.

    Plugin Author Frank Goossens

    (@futtta)

    don’t have a date for the next release really, but you can follow up on progress on github (currently a mix of smaller improvements & fixes for issues like this one, but some major changes in the pipeline still to be implemented).

    frank

Viewing 15 replies - 1 through 15 (of 15 total)
  • The topic ‘Autoptimize removing backslashes from comments’ is closed to new replies.