-
Notifications
You must be signed in to change notification settings - Fork 3.7k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Improve JSON output when there is leading data before the actual JSON body #1130
Improve JSON output when there is leading data before the actual JSON body #1130
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1130 +/- ##
==========================================
- Coverage 97.28% 97.24% -0.05%
==========================================
Files 67 70 +3
Lines 4235 4279 +44
==========================================
+ Hits 4120 4161 +41
- Misses 115 118 +3
Continue to review full report at Codecov.
|
This comment has been minimized.
This comment has been minimized.
The prefix is printed before the prettified JSON: I am not sure yet how to set a specific color for the prefix @jakubroztocil. Do you have a clue 🙏? |
Take a look at what tokens Pygments works with. I’d probably experiment with comments, exceptions, errors, etc. Perhaps you could even generate an example for each token type to see what feels right? https://github.com/pygments/pygments/blob/master/pygments/token.py#L123-L212 |
Here we are. Actually, I prefer no color. But Maybe the "error" style is better to highlight data not being taken into account by the parser? FTR there is no style for comments, and the number style is the same as "keyword" one. So it seems we have only those choices by default. |
From those four I’d pick error. But I’m wondering how the different comment tokens would look like. Could you write a loop over all the tokens and print the name and the output for each so that we can compare them? |
Actually there are no "comment" token styles because JSON does not support comments. |
Both requests and responses are handled on purpose. |
/packit build |
I resolved the conflict, the patch is good for a final review :) |
…JSON data In some special cases, to prevent against Cross Site Script Inclusion (XSSI) attacks, the JSON response body starts with a magic prefix line that must be stripped before feeding the rest of the response body to the JSON parser. Such prefix is now simply ignored from the parser but still printed in the terminal.
Merging PR as changes are quite correct and all tests are green. |
In some special cases, to prevent against Cross Site Script Inclusion (XSSI) attacks, the JSON response body starts with a magic prefix line that must be stripped before feeding the rest of the response body to the JSON parser.
Such prefix is now simply ignored from the parser but still printed in the terminal.
Supersedes #529.