Commit 56ddd01d authored by brizental's avatar brizental Committed by Pier Angelo Vendrame
Browse files

fixup! TB 40458: Implement .tor.onion aliases

parent d1c0c433
Loading
Loading
Loading
Loading
+7 −8
Original line number Diff line number Diff line
@@ -175,17 +175,15 @@ class Channel {
        );
        return;
      }
      let toHostname;
      try {
        const toUrl = new URL(rule.rule[0].to);
        toHostname = toUrl.hostname;
      } catch (err) {
      const toHostname = URL.parse(rule.rule[0].to)?.hostname;
      if (!toHostname) {
        log.error(
          "Cannot detect the hostname from the to rule",
          rule.rule[0].to,
          err
          "Unable to parse the URL and the hostname from the to rule",
          rule.rule[0].to
        );
        return;
      }

      let fromRe;
      try {
        fromRe = new RegExp(rule.rule[0].from);
@@ -318,6 +316,7 @@ class _OnionAliasStore {
      throw Error("Name cannot be empty");
    }

    // This will throw if the URL is invalid.
    new URL(chanData.pathPrefix);
    const scope = new RegExp(chanData.scope);
    const ch = new Channel(
+8 −1
Original line number Diff line number Diff line
@@ -79,7 +79,14 @@ class RequestObserver {
  }

  isCrossOrigin(url1, url2) {
    return new URL(url1).origin !== new URL(url2).origin;
    const origin1 = URL.parse(url1)?.origin;
    const origin2 = URL.parse(url2)?.origin;

    if (!origin1 || !origin2) {
      return true;
    }

    return origin1 !== origin2;
  }
  shouldBlindCrossOrigin(uri) {
    try {
+2 −2
Original line number Diff line number Diff line
@@ -210,8 +210,8 @@ class EditState {

    const pathPrefix = elements.pathPrefixInput.value.trim();
    try {
      const url = new URL(pathPrefix);
      if (url.protocol !== "http:" && url.protocol !== "https:") {
      const url = URL.parse(pathPrefix);
      if (url?.protocol !== "http:" && url?.protocol !== "https:") {
        elements.pathPrefixInput.setCustomValidity(
          await document.l10n.formatValue("rulesets-details-path-input-invalid")
        );