@@ -27,6 +27,7 @@ import (
2727
2828 "github.com/nitrictech/cli/pkg/cloud/apis"
2929 "github.com/nitrictech/cli/pkg/cloud/batch"
30+ "github.com/nitrictech/cli/pkg/cloud/env"
3031 "github.com/nitrictech/cli/pkg/cloud/gateway"
3132 "github.com/nitrictech/cli/pkg/cloud/http"
3233 "github.com/nitrictech/cli/pkg/cloud/keyvalue"
@@ -36,7 +37,6 @@ import (
3637 "github.com/nitrictech/cli/pkg/cloud/secrets"
3738 "github.com/nitrictech/cli/pkg/cloud/sql"
3839 "github.com/nitrictech/cli/pkg/cloud/storage"
39- "github.com/nitrictech/cli/pkg/cloud/env"
4040 "github.com/nitrictech/cli/pkg/cloud/topics"
4141 "github.com/nitrictech/cli/pkg/cloud/websites"
4242 "github.com/nitrictech/cli/pkg/cloud/websockets"
@@ -259,6 +259,11 @@ type LocalCloudOptions struct {
259259func New (projectName string , opts LocalCloudOptions ) (* LocalCloud , error ) {
260260 hostname := env .NITRIC_HOSTNAME .String ()
261261
262+ // Reject hostnames containing characters that would produce malformed URLs
263+ if strings .ContainsAny (hostname , "/?#\r \n \t " ) {
264+ return nil , fmt .Errorf ("NITRIC_HOSTNAME contains invalid characters: %q" , hostname )
265+ }
266+
262267 // Bracket IPv6 literals for use in URLs (RFC 3986)
263268 if strings .Contains (hostname , ":" ) && ! strings .HasPrefix (hostname , "[" ) {
264269 hostname = "[" + hostname + "]"
0 commit comments