Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Escape ‘%’ in console.OutStyle arguments #4026

Merged
merged 1 commit into from
Apr 11, 2019

Conversation

11janci
Copy link
Contributor

@11janci 11janci commented Mar 31, 2019

Escape arguments to console.OutStyle so that '%' signs get printed out instead of being interpreted as formatting directives and printed out like %!e(MISSING)
Closes #4025

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Mar 31, 2019
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: 11janci
To fully approve this pull request, please assign additional approvers.
We suggest the following additional approver: dlorenc

If they are not already assigned, you can assign the PR to them by writing /assign @dlorenc in a comment when ready.

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label Mar 31, 2019
@minikube-bot
Copy link
Collaborator

Can one of the admins verify this patch?

@11janci
Copy link
Contributor Author

11janci commented Mar 31, 2019

/assign @dlorenc

Copy link
Collaborator

@afbjorklund afbjorklund left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, does it need a test perhaps ?

@tstromberg
Copy link
Contributor

Agreed. This will definitely need an addition to console_test.go.

@tstromberg
Copy link
Contributor

@minikube-bot OK to test

outStyled, err := applyStyle(style, useColor, format, a...)
// format the output string and escape any outstanding '%' signs so that they don't
// get interpreted as a formatting directive down the line
outStyled = strings.Replace(outStyled, "%", "%%", -1)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should probably use % instead of "%"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is just a github thing, neither IDE nor gofmt complains

Copy link
Contributor

@tstromberg tstromberg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR! I'll approve once it has a test to verify that we don't break this again in the future.

@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Apr 5, 2019
@11janci
Copy link
Contributor Author

11janci commented Apr 5, 2019

@tstromberg @afbjorklund done, thanks for pointing to the test, now I found it was also broken for ErrStyle()...

/ptal

@11janci
Copy link
Contributor Author

11janci commented Apr 7, 2019

/retest

@k8s-ci-robot
Copy link
Contributor

@11janci: Cannot trigger testing until a trusted user reviews the PR and leaves an /ok-to-test message.

In response to this:

/retest

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@tstromberg tstromberg merged commit e316a4d into kubernetes:master Apr 11, 2019
@11janci 11janci deleted the jjanik-console-escaping branch July 14, 2020 09:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants