• Resolved tremlas

    (@tremlas)


    My site includes the occasional piece of inline style. One of those pieces is “<style>.allpostslist li:before { content: ‘\2022’; }</style>”. With version 2.2.3 of simply static the backslash is removed from the content leaving it as “content: ‘2022’”. Obviously this changes what’s supposed to be a unicode bullet into 2022. Version 2.2.2 (which I’ve rolled back to) doesn’t do this.

Viewing 2 replies - 1 through 2 (of 2 total)
  • After updating to 2.2.3, my site experienced the same issue:
    An inline JavaScript stopped working because backslashes have been removed.

    Comparing version 2.2.2 and 2.2.3 showed that it happens in
    "/src/class-ss-url-extractor.php"
    where in two functions a new stripslashes() has been inserted in 2.2.3

    function extract_and_replace_urls_in_html()
        $html_string = $this->get_body();
        $html_string = stripslashes( $html_string ); // 2.2.3
    
    function extract_and_replace_urls_in_script( $text )
        $text = stripslashes( $text );    // 2.2.3

    Because parameters $html_string and $text contained following (truncated) JS code, in the generated static pages, this JS code failed.

    ... "<span class=\"ast-icon icon-close\" ><\/span >" ...

    By removing these stripslashes()calls, Simply Static 2.2.3 again worked fine as version 2.2.2.

    But what about replacing URLs with rare/unusual encoding (in JS/CSS) ?
    Can we avoid stripslashes()calls and still replace all kind of encoded URLs?

    One possibility would be, by using arrays containing all (most) possible encoded URL pairs for the replacement:

    // prepare encoded URL pairs for replacement:
    $dyn[0..n]  = DYNAMIC_URLs; // encoded source URLs
    $stat[0..n] = STATIC_URLs;  // corresponding replacements
    
    str_replace( $string, $dyn, $stat );

    It would also help to provide extra filters, that allow replacing special cases of encoded URLs by using the provided URL strings to perform its own str_replace() to cover special cases.
    For example:

    apply_filters( 'ss_fix_urls', $text, $url_dyn, $url_static) 

    Last not least:
    Thank you for providing Simply Static, it works great!
    /GeHo

    Plugin Author patrickposner

    (@patrickposner)

    @tremlas @geho01 it’s reverted now in 2.2.4!

    @geho01 That’s a pretty good idea! If you like you can submit a pull request on GitHub. We are currently keeping track of that issue here: https://github.com/patrickposner/simply-static/issues/77

    I will soon modify the description of the issue and collect all the details + use cases!

    Best regards,

    Patrick

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Version 2.2.3 mangles inline style content’ is closed to new replies.