Issue #2400287 by hass, cutesquirrel, borisson_, rteijeiro, aerozeppelin, yuriy.babenko, cyb.tachyon, pfrenssen, deanflory, webchick, David_Rothstein, cilefen, aspilicious, netbek, stefan.r, moshe weitzman, nod_, minakshiPh, pandaski: Remove all occurences of sourceMappingURL and sourceURL when JS files are aggregated

merge-requests/599/head
mcdruid 2021-04-05 11:59:41 +01:00
parent 16410c623a
commit fbb5903edb
1 changed files with 2 additions and 0 deletions

View File

@ -5166,6 +5166,8 @@ function drupal_build_js_cache($files) {
$contents .= file_get_contents($path) . ";\n";
}
}
// Remove JS source and source mapping urls or these may cause 404 errors.
$contents = preg_replace('/\/\/(#|@)\s(sourceURL|sourceMappingURL)=\s*(\S*?)\s*$/m', '', $contents);
// Prefix filename to prevent blocking by firewalls which reject files
// starting with "ad*".
$filename = 'js_' . drupal_hash_base64($contents) . '.js';