Browse Source

Cleanup

microsub
J. King 5 years ago
parent
commit
12fe786a2f
  1. 8
      lib/Misc/URL.php

8
lib/Misc/URL.php

@ -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;

Loading…
Cancel
Save