1
1
Fork 0
mirror of https://code.mensbeam.com/MensBeam/Arsse.git synced 2025-01-11 18:32:41 +00:00
This commit is contained in:
J. King 2019-08-29 12:28:23 -04:00
parent d4802bcdb6
commit 12fe786a2f

View file

@ -45,9 +45,9 @@ class URL {
} }
$out = strtolower($scheme)."://"; $out = strtolower($scheme)."://";
if (strlen($u ?? "")) { if (strlen($u ?? "")) {
$out .= self::normalizePart(rawurlencode($u), self::P_USER, false); $out .= self::normalizePart(rawurlencode($u), self::P_USER);
if (strlen($p ?? "")) { if (strlen($p ?? "")) {
$out .= ":".self::normalizePart(rawurlencode($p), self::P_PASS, false); $out .= ":".self::normalizePart(rawurlencode($p), self::P_PASS);
} }
$out .= "@"; $out .= "@";
} elseif (strlen($user ?? "")) { } elseif (strlen($user ?? "")) {
@ -66,11 +66,13 @@ class URL {
return $out; return $out;
} }
protected static function normalizePart(string $part, int $type, bool $passthrough_encoded = true): string { /** Perform percent-encoding normalization for a given URL component */
protected static function normalizePart(string $part, int $type): string {
// stub // stub
return $part; return $part;
} }
/** Normalizes a hostname per IDNA:2008 */
protected static function normalizeHost(string $host): string { protected static function normalizeHost(string $host): string {
$idn = idn_to_ascii($host, \IDNA_NONTRANSITIONAL_TO_ASCII, \INTL_IDNA_VARIANT_UTS46); $idn = idn_to_ascii($host, \IDNA_NONTRANSITIONAL_TO_ASCII, \INTL_IDNA_VARIANT_UTS46);
return $idn !== false ? idn_to_utf8($idn, \IDNA_NONTRANSITIONAL_TO_UNICODE, \INTL_IDNA_VARIANT_UTS46) : $host; return $idn !== false ? idn_to_utf8($idn, \IDNA_NONTRANSITIONAL_TO_UNICODE, \INTL_IDNA_VARIANT_UTS46) : $host;