Skip to content

orgs select hint interpolates org name unquoted, producing an unpasteable command #7

Description

@gdameneses

Summary

When urlbox orgs select lands in an org with several projects, the hint it prints interpolates the organisation name unquoted. Any org name containing an apostrophe or a space produces a command that cannot be pasted into a shell.

Reproduce

  1. Be in an org whose name contains an apostrophe — the default "'s Organisation" that Urlbox creates for a new account is exactly this shape.

  2. Trigger the multi-project branch without a TTY:

    urlbox orgs select "<that org>" | cat

Expected

A copy-pasteable command.

Actual

6 projects in this organisation — run `urlbox orgs select Some User's Organisation --project <name>` or `urlbox projects select` to finish.

Pasting that leaves the shell waiting on an unterminated quote. Even without the apostrophe, the unquoted spaces mean orgs select receives only the first word.

Cause

internal/cmd/orgs.go:212 used %s for the name:

_, _ = fmt.Fprintf(cmd.ErrOrStderr(),
	"%d projects in this organisation — run `urlbox orgs select %s --project <name>` or `urlbox projects select` to finish.\n",
	projectCount, chosen.Name)

Fix

%q quotes the name and escapes what needs escaping:

	"%d projects in this organisation — run `urlbox orgs select %q --project <name>` or `urlbox projects select` to finish.\n",

Output becomes:

run `urlbox orgs select "Some User's Organisation" --project <name>`

which pastes correctly. Other hints that interpolate user-controlled names into suggested commands are worth the same check.

Environment

urlbox 1.2.0 (commit 5530665), Linux.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions