ascii art, that’s obscure (but cool) allright 😉
put the entire block between noptimize-tags (see FAQ) and all should be fine?
frank
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 http://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!
ah, small mistake in how you implemneted noptimize actually, should be;
<!--noptimize-->
This site was made with
/$$ /$$$$$$ /$$ /$$ /$$$$$$$$ /$$$ /$$ /$$ /$$$$$$ /$$ /$$ /$$$$$$$$ /$$ /$$
| $$ /$$__ $$| $$ | $$| $$_____/ /$$ $$ | $$$ /$$$ /$$__ $$| $$$ | $$| $$_____/| $$ /$$/
| $$ | $$ \ $$| $$ | $$| $$ | $$$ | $$$$ /$$$$| $$ \ $$| $$$$| $$| $$ \ $$ /$$/
| $$ | $$ | $$| $$ / $$/| $$$$$ /$$ $$/$$ | $$ $$/$$ $$| $$ | $$| $$ $$ $$| $$$$$ \ $$$$/
| $$ | $$ | $$ \ $$ $$/ | $$__/ | $$ $$_/ | $$ $$$| $$| $$ | $$| $$ $$$$| $$__/ \ $$/
| $$ | $$ | $$ \ $$$/ | $$ | $$\ $$ | $$\ $ | $$| $$ | $$| $$\ $$$| $$ | $$
| $$$$$$$$| $$$$$$/ \ $/ | $$$$$$$$ | $$$$/$$ | $$ \/ | $$| $$$$$$/| $$ \ $$| $$$$$$$$ | $$
|________/ \______/ \_/ |________/ \____/\_/ |__/ |__/ \______/ |__/ \__/|________/ |__/
http://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.
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
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.
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
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.ww.wp.xz.cn/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.
OK, modified this in the Github-version, cfr. commit https://github.com/futtta/autoptimize/commit/1ddc83585dc1099a2fa6a114f679b50d5f8a4969
thanks for reporting & assisting!
frank
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.
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