Closed DahmaniAdame closed 4 months ago
An additional note to what @DahmaniAdame wrote.
That file is among those we automatically exclude for Uncode, and therefore there isn't a need to be added in the exclusion text area: https://github.com/wp-media/wp-rocket/blob/59045e5ace9948b5ad844c6f4d5c46122089af7b/inc/3rd-party/themes/uncode.php#L20
Also, the same issue will occur when excluding any of the files there, e.g.:
/library/js/min/ai-uncode.min.js
Reproduced on local test site
there are two problems here
The Uncode them use this filter to add extra attributes to the script tag that contains "ai-uncode"
add_filter('clean_url','uncode_unclean_url',10,3);
function uncode_unclean_url( $good_protocol_url, $original_url, $_context){
...
return apply_filters( 'uncode_ai_script_path', $url_parts['path'], $url_parts ) . "' " . $data_mobile_advanced
"id='uncodeAI'".$ai_async." data-home='".$url_home."' data-path='".$path_domain."' data-breakpoints-images='" . $ai_sizes;
...
}
in "themes/uncode/core/inc/main.php"
so when esc_url() wp function is called the extra attributes will be added to the URL
"rocket_is_internal_file" not working correctly with internal files without the domain
when you add "/library/js/min/ai-uncode.min.js" in exclude text area this function "rocket_is_internal_file" will return that the file is external
and the First Problem will happen because the function "rocket_validate_css" will use "esc_url_raw" that adds the extra Encode theme attributes
we can add this this function "is_external_path" in "inc/Engine/Optimization/CSSTrait.php" in "wp-content/plugins/wp-rocket/inc/functions/formatting.php"
and use it instead of "rocket_is_internal_file"
this will fix the second problem and this Issue because the file will be treated as an internal resource
Effort [XS]
There's no feedback from customers regarding this one. It's not going to be implemented in the near future. We're open to discuss and reopen the issue though.
Before submitting an issue please check that you’ve completed the following steps:
Describe the bug When trying to exclude the following file on Uncode
/wp-content/themes/uncode/library/js/ai-uncode.js
, the following string appends to it'%20id='uncodeAI'%20data-home='/'%20data-path='/'%20data-breakpoints-images='' id='uncodeAI' data-home='/' data-path='/' data-breakpoints-images='
on each save.After many saves, this ultimately results in
Compilation failed: regular expression is too large
.Likely a Regex issue when extracting the script path:
To Reproduce Steps to reproduce the behavior:
/wp-content/themes/uncode/library/js/ai-uncode.js
Expected behavior We should only add
/wp-content/themes/uncode/library/js/ai-uncode.js
to the exclusion list.Screenshots
Additional context Ticket - https://secure.helpscout.net/conversation/1531260252/268617?folderId=3864735 Confirmed on Mega/Uncode
Backlog Grooming (for WP Media dev team use only)