WordPress.org

Forums

Codestyling Localization
[resolved] *** FIX *** Script analyze (1 post)

  1. Adrian Preuß
    Member
    Posted 1 year ago #

    A lot of Scripts are not text/javascript. The media manager and other plugins can add text/css or text/html. That code will be parsed and make some problems (see Screenshots):

    Screenshot 1
    Screenshot 2

    Here is a little fix to check the <script>-Tag type:

    codestyling-localization.php
    First: Replace all $scripts[1][$i] from line 2608 up to line 2641 with $scripts[2][$i]

    And than modify the code-analyze block:
    OLD regular expression on line 2608:

    if (preg_match_all("/<script[^>]*>([\s\S]*?)<\/script>/i", $content, $scripts)) {

    NEW (Modify first RegExpr to ([^>]+)):

    if (preg_match_all("/<script([^>]+)*>([\s\S]*?)<\/script>/i", $content, $scripts)) {

    OLD line 2610:

    for($i=0; $i<$num; $i++) {

    NEW (Adding new line to check the type):

    for($i=0; $i<$num; $i++) {
    	if(preg_match('/type="(text\/html|text\/css)"/Uis', $scripts[1][$i])) {
    				continue;
    			}

    Info: This fix is only for the Footer scripts (function csp_self_script_protection_footer). The same fix must be replaced for the header scripts.
    https://wordpress.org/plugins/codestyling-localization/

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic