sourcehost

package
v0.2.12 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 14, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package sourcehost compares the host a Git or HTTPS source names with a host something else grants: the host key of a credential Secret, or an entry of a source policy's allowedGitHosts or allowedHTTPSHosts.

A host is compared as ASCII. url.Parse accepts UTF-8 in a host and decodes a percent-escaped one, and Go's HTTP transport dials such a host by its IDNA form: https://g%C4%B0thub.com/, "g", U+0130 and "thub.com", dials xn--github-qyd.com. A comparison that folds Unicode case reads that host as github.com, since strings.ToLower maps U+0130 to "i", and holds a grant for one name to a server under another. So a host that holds a byte outside printable ASCII is refused, and an internationalized name is written in its xn-- form.

Index

Constants

This section is empty.

Variables

View Source
var ErrNotASCII = errors.New("write an internationalized name in its xn-- form")

ErrNotASCII is the refusal of a host that holds a byte outside printable ASCII, matched with errors.Is.

Functions

func Authority

func Authority(rawURL string) (string, error)

Authority is the host[:port] a source URL names, as url.Parse reads it, percent escapes decoded. It refuses a URL url.Parse refuses and a host that is not printable ASCII.

func CheckASCII

func CheckASCII(authority string) error

CheckASCII refuses a host[:port] that holds a byte outside printable ASCII, naming it with every such byte escaped.

func Equal

func Equal(left, right string) bool

Equal reports whether two authorities are the same host[:port], byte for byte but for the case of ASCII letters. An authority that is empty, or holds a byte outside printable ASCII, equals nothing, itself included.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL