Files
html/api/ambre-regex-direct-fix.php
2026-04-22 01:40:03 +02:00

37 lines
1.4 KiB
PHP

<?php
header("Content-Type: text/plain");
$file = "/var/www/html/wevia.html";
$content = file_get_contents($file);
$len_before = strlen($content);
// The broken regex on line 1503 uses [.*+?^${}()|[\]\\/] which has [] inside [] chars -- INVALID
// Replace with safer version using non-class-based escape
$broken = 'var _escUrl = finalFileUrl.replace(/[.*+?^${}()|[\]\\\\\/]/g, \'\\\\$&\');';
$fixed = 'var _escUrl = finalFileUrl.split(/([^A-Za-z0-9])/).map(function(p,i){return i%2?"\\\\"+p:p;}).join("");';
if (strpos($content, $broken) !== false) {
$new_content = str_replace($broken, $fixed, $content);
// GOLD backup
$gold = "/opt/wevads/vault/wevia.html.GOLD-" . date("Ymd-His") . "-regex-fix";
@copy($file, $gold);
// Write
@chattr_remove(); // ignore - chattr might not be set
file_put_contents($file, $new_content);
echo "FIXED! delta=" . (strlen($new_content) - $len_before) . " gold=$gold\n";
} else {
echo "Pattern not found in file\n";
// Show what we have at line 1503
$lines = explode("\n", $content);
echo "Line 1503: " . ($lines[1502] ?? "N/A") . "\n";
// Extract exact bytes
$line = $lines[1502];
$pos_var = strpos($line, "var _escUrl");
if ($pos_var !== false) {
echo "Bytes 60-200: " . bin2hex(substr($line, 60, 50)) . "\n";
}
}
function chattr_remove(){ @shell_exec("chattr -i /var/www/html/wevia.html 2>&1"); }