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

Fixed handling of '%' in debugger styled output #260

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

akrainiouk
Copy link
Contributor

Currently if the value contains % character, the debugger styled output attempts to interpret it as a format specifier which leads to garbled output.
For example this statement:

  set req.http.foo = {"foo%bar"};

Is displayed as:

set req.http.foo = {"foo%!!(MISSING)b(MISSING)ar"};

The problem is that in the code a string value often passed as a single argument to the functions from colors package which means they are interpreted as a format specifier.
Instead of fixing the usages, the fix creates a wrapper around fmd.Sprintf which automatically detects above usage and turns it into 2 argument call:
fmt.Sprintf(someString) ==> fmtSprint("%s", someString)

@akrainiouk
Copy link
Contributor Author

Another commit that provides cleaner fix for % character rendering.
Turns out that format arguments are never used in the code so we can safely turn color.* functions to a single argument.

Note that there is a bigger (although less exposed) issue with the debugger text rendering. The problem is that if printed value itself contains any of they style tags they will get interpreted as colors rather than taken literally.
This can be reproduced easily by simply starting the debugger and trying to type the following in the debugger console:

foo[blue]bar

instead of taken literally '[blue]' is interpreted as a color tag.
The same applies to printed values as well as the source text.
I did not attempt to fix this last issue as it might require deeper changes than I am comfortable with.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant