Skip to content

Consolidate URL validation: share the insecure-server guard and the authority-safety check #1731

Description

@quietbits

Problem

The SDK validates URLs in several unrelated places, and the copies have started to drift.

The "cannot connect to insecure server" guard is duplicated across the Horizon, RPC, and Federation servers. Horizon and Federation fall back to the global Config.allowHttp setting; RPC reads only its per-call option, so setting allowHttp globally has no effect on RPC even though its documentation says it does.

The authority-safety check — the logic that keeps a malformed domain from redirecting the request — lives inside the TOML resolver and cannot be reused. Federation needs the same protection and has no access to it.

Proposed solution

Extract the insecure-server guard into one helper shared by all three servers, and move the authority-safety check into a shared URL utility so the TOML resolver and Federation both use it. Federation's RFC 1035 grammar check stays separate and specific to Federation — it enforces a different rule, and folding it in would change which domains each one accepts.

Breaking?

No, in practice. Each server keeps its own error message. RPC starts honoring the global setting, which only permits what was previously refused. The one behavior change is that constructing a FederationServer with an out-of-range port would newly throw, and such a port cannot produce a working request today.

Related

Worth its own issue: Federation's domain check rejects valid domains whose first character is a digit, because it implements RFC 1035 preferred-name syntax literally. RFC 1123 requires host software to accept a leading digit.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    • Status
      Todo (Ready for Dev)

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions