fix: sanitize server text in pull request messages, auth status and notification watch

Signed-off-by: bircni <bircni@icloud.com>
This commit is contained in:
bircni committed 2026-10-18 17:19:10 +02:00
1 parent 04ad230d59
commit 3d10badb8b
4 files changed
+9 -5

No files matched your search

+2 -2
View File
@@ -578,7 +578,7 @@ func statusLine(row authStatusRow, d terminal.Display) string {
if row.environment() {
line = "Using GITEA_TOKEN from the environment"
if row.User != "" {
line += " as " + terminal.Emphasis(row.User, d.Color)
line += " as " + terminal.Emphasis(terminal.SafeLine(row.User), d.Color)
}
} else {
line = "Logged in as " + terminal.Emphasis(terminal.SafeLine(row.User), d.Color) + " " + muted("("+credentialLabel(row.account)+")")
@@ -597,7 +597,7 @@ func statusLine(row authStatusRow, d terminal.Display) string {
if row.Verified != nil && *row.Verified {
note := "verified"
if len(row.Scopes) > 0 {
note += ", scopes: " + strings.Join(row.Scopes, ", ")
note += ", scopes: " + terminal.SafeLine(strings.Join(row.Scopes, ", "))
}
notes = append(notes, note)
}
+1 -1
View File
@@ -167,7 +167,7 @@ func (a *application) created(cmd *cobra.Command, item any, url string) error {
// refLabel names an issue or pull request in feedback: "alice/x#5 (Fix login)".
func refLabel(repo string, number int64, title string) string {
return fmt.Sprintf("%s#%d (%s)", repo, number, title)
return fmt.Sprintf("%s#%d (%s)", repo, number, terminal.SafeLine(title))
}
// abortBatch stops a batch instead of recording an item failure.
+4
View File
@@ -406,3 +406,7 @@ func TestShowing(t *testing.T) {
require.Equal(t, tc.want, showing(tc.shown, tc.page, "open issues"), "%+v", tc.page)
}
}
func TestRefLabelDropsTerminalControls(t *testing.T) {
require.Equal(t, "alice/x#5 (fix ]0;pwnevil)", refLabel("alice/x", 5, "fix \x1b]0;pwn\x07evil"))
}
+2 -2
View File
@@ -400,9 +400,9 @@ func watchLine(item services.Notification, d terminal.Display) string {
when = d.Now
}
subject := subjectRef(item)
details := strings.ToLower(item.Type)
details := terminal.SafeLine(strings.ToLower(item.Type))
if item.State != "" {
details += " · " + terminal.Colorize(stateColors[item.State], item.State, d.Color)
details += " · " + terminal.Colorize(stateColors[item.State], terminal.SafeLine(item.State), d.Color)
}
return terminal.Colorize("muted", when.Local().Format("15:04"), d.Color) + " " + terminal.Emphasis(terminal.SafeLine(subject), d.Color) + " " + terminal.SafeLine(item.Title) + " " + details
}