• WP Fastest Cache adds String “<!– html is corrupted –>” to end of JSON/REST-API output of WordPress which leads to invalid JSON.

    Examples:

    • hXXp://www.wpfastestcache.com/wp-json/wp/v2/posts
    • hXXp://www.wpfastestcache.com/wp-json/wp/v2/users

    Please fix soon, thanks.

    • This topic was modified 9 years, 3 months ago by ov3rfly.
Viewing 15 replies - 16 through 30 (of 31 total)
  • Thread Starter ov3rfly

    (@ov3rfly)

    No need to detect json pages or similar. Start thinking the other way round, only add HTML-comments if you know it is HTML-data. Problem solved.

    Plugin Author Emre Vona

    (@emrevona)

    WP Fastest Cache adds String “<!– html is corrupted –>” to end of JSON/REST-API output of WordPress which leads to invalid JSON.

    Examples:

    hXXp://www.wpfastestcache.com/wp-json/wp/v2/posts
    hXXp://www.wpfastestcache.com/wp-json/wp/v2/users
    Please fix soon, thanks.

    I have fixed it few minutes ago but I did not release a new version. You should download the following version.

    https://downloads.wp.xz.cn/plugin/wp-fastest-cache.zip

    Thread Starter ov3rfly

    (@ov3rfly)

    Testcases on your server still have <!– html is corrupted –> added.

    Downloaded .zip says 0.8.6.6 in header and still has this code in ../inc/cache.php which obviously will print the comment to anything which does not have an html and body tag.

    }else if($this->checkHtml($buffer)){
    	return $buffer."<!-- html is corrupted -->";
    }else

    Let me know if a real fix as described above is ready, take your time, as described this can not be solved by comparing some strings in URLs.

    Thanks for the quick feedback.

    Plugin Author Emre Vona

    (@emrevona)

    I have added the following code.

    if(preg_match(“/^\/wp-json/”, $_SERVER[“REQUEST_URI”])){
    return true;
    }

    Thread Starter ov3rfly

    (@ov3rfly)

    As explained, that’s not a real fix, just a quick hack workaround which does not cover all kind of other endpoints which deliver JSON or similar.

    Start thinking the other way round, only add HTML-comments if you know it is HTML-data. Problem solved.

    Plugin Author Emre Vona

    (@emrevona)

    You are %100 right but I cannot detect that the page is html or json. You should get and use the temp solution.

    Thread Starter ov3rfly

    (@ov3rfly)

    As explained, if you cannot detect html or json, do not add HTML-comments.

    Minimum fix:

    }else if($this->checkHtml($buffer)){
    	return $buffer;
    }else

    Minimum fix with debug info:

    }else if($this->checkHtml($buffer)){
    	if ( WP_DEBUG ) error_log( 'WPFC: <!– html is corrupted –>' );
    	return $buffer;
    }else
    Plugin Author Emre Vona

    (@emrevona)

    ok, you are right.

    Is this fixed yet?

    Plugin Author Emre Vona

    (@emrevona)

    Hi @songofhannah, The urls which start with /wp-json/ are not cached with the following version.

    https://downloads.wp.xz.cn/plugin/wp-fastest-cache.zip

    The URL above looks to be the WP latest version. So all I need to do it update, right?

    Thread Starter ov3rfly

    (@ov3rfly)

    The code in 0.8.6.7 still adds HTML-comments to any non-HTML data.

    Please add a real fix as described above.

    Excluding certain URLs from cache just hides the problem and actually also defeats the purpose of a cache plugin.

    Plugin Author Emre Vona

    (@emrevona)

    The URL above looks to be the WP latest version. So all I need to do it update, right?

    yes.

    The code in 0.8.6.7 still adds HTML-comments to any non-HTML data.

    Please add a real fix as described above.

    Excluding certain URLs from cache just hides the problem and actually also defeats the purpose of a cache plugin.

    Please contact me via email: http://www.wpfastestcache.com/contact-us/

    Thread Starter ov3rfly

    (@ov3rfly)

    The code in 0.8.6.7 still adds HTML-comments to any non-HTML data.

    This bug still affects any custom WordPress endpoints.

    How to reproduce? Create an own endpoint.

    Find a full example as plugin here, link to github gist at end of article.

    With above plugin, add a “GIFs” item with a tag sdf

    Open link to endpoint in browser: http://example.com/gifs/sdf/

    Get corrupted JSON:

    [{"link":"http:\/\/example.com\/wp-content\/uploads\/2017\/01\/example.jpg","title":"test"}]<!-- html is corrupted -->

    Another Link with non-existing GIF-tag: http://example.com/gifs/yxcvb/

    []<!-- html is corrupted -->

    No need to contact you via email, there is enough information above already.

    The real fix: Only add HTML-comments if you know it is HTML-data. If you can’t detect page format, do not add anything at all. Problem solved.

    Plugin Author Emre Vona

    (@emrevona)

    @ov3rfly, please contact me via email and I will fix it.

    http://www.wpfastestcache.com/contact-us/

Viewing 15 replies - 16 through 30 (of 31 total)

The topic ‘Breaks JSON/REST-API Output’ is closed to new replies.