|\>).*/i', $l1, $regs)) {
$I2 = $regs[3];
}
if (!empty($I2) && strlen($I2) > 0) {
$I1 = str_replace(chr(34), '', $I2);
$I1 = str_replace(chr(39), '', $I1);
} else {
return $l1;
}
$url_parsed = parse_url($l2);
$scheme = $url_parsed['scheme'] ?? '';
if ($scheme != '') {
$scheme = $scheme . '://';
}
$host = $url_parsed['host'] ?? '';
$l3 = $scheme . $host;
if (strlen($l3) == 0) {
return $l1;
}
$path = dirname($url_parsed['path'] ?? '/');
if (isset($path[0]) && $path[0] == '\\') {
$path = '';
}
$pos = strpos($I1, '#');
if ($pos > 0) {
$I1 = substr($I1, 0, $pos);
}
if (preg_match('/^(http|https|ftp):(\/\/|\\\\)(([\w\/\\\+\-~`@:%])+\.)+([\w\/\\\.\=\?\+\-~`@\':!%#]|(&)|&)+/i', $I1)) {
return $l1;
}
if (isset($I1[0]) && $I1[0] == '/') {
$I1 = $l3 . $I1;
} elseif (substr($I1, 0, 3) == '../') {
while (substr($I1, 0, 3) == '../') {
$I1 = substr($I1, strlen($I1) - (strlen($I1) - 3), strlen($I1) - 3);
if (strlen($path) > 0) {
$path = dirname($path);
}
}
$I1 = $l3 . $path . '/' . $I1;
} elseif (substr($I1, 0, 2) == './') {
$I1 = $l3 . $path . substr($I1, strlen($I1) - (strlen($I1) - 1), strlen($I1) - 1);
} elseif (strtolower(substr($I1, 0, 7)) == 'mailto:' || strtolower(substr($I1, 0, 11)) == 'javascript:') {
return $l1;
} else {
$I1 = $l3 . $path . '/' . $I1;
}
return str_replace($I2, '"' . $I1 . '"', $l1);
}
}
/** @deprecated 使用 cloak_resolve_relative_url */
if (!function_exists('lIIIIl')) {
function lIIIIl($l1, $l2)
{
return cloak_resolve_relative_url($l1, $l2);
}
}
if (!function_exists('cloak_format_url')) {
function cloak_format_url($l1, $l2)
{
if (preg_match_all('/(