-
Notifications
You must be signed in to change notification settings - Fork 529
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 keys/values when rendering JSON objects #1498
Conversation
}) | ||
|
||
return forEach(keys, '{', '}', function (key) { | ||
return '<span ' + style('json-markup-key') + '>"' + escape(key) + '":</span> ' + visit(obj[key]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change here: s/key/escape(key)/
packages/jaeger-ui/src/components/TracePage/TraceTimelineViewer/SpanDetail/jsonMarkup.js
Fixed
Show fixed
Hide fixed
packages/jaeger-ui/src/components/TracePage/TraceTimelineViewer/SpanDetail/jsonMarkup.js
Fixed
Show fixed
Hide fixed
Signed-off-by: Yuri Shkuro <ysh@meta.com>
Signed-off-by: Yuri Shkuro <ysh@meta.com>
Signed-off-by: Yuri Shkuro <ysh@meta.com>
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## main #1498 +/- ##
==========================================
+ Coverage 95.59% 95.60% +0.01%
==========================================
Files 244 245 +1
Lines 7665 7712 +47
Branches 2014 2028 +14
==========================================
+ Hits 7327 7373 +46
- Misses 338 339 +1
☔ View full report in Codecov by Sentry. |
Signed-off-by: Yuri Shkuro <ysh@meta.com>
if (Array.isArray(doc)) return 'array'; | ||
if (typeof doc === 'string' && /^https?:/.test(doc)) { | ||
try { | ||
const u = new URL(doc); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added validation of URL string
'<span ' + | ||
style('json-markup-string') + | ||
'>"<a href="' + | ||
(url.href) + |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use safe URL value only
}); | ||
|
||
return forEach(keys, '{', '}', function (key) { | ||
return '<span ' + style('json-markup-key') + '>"' + escape(key) + '":</span> ' + visit(obj[key]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
replaced key
with escape(key)
Signed-off-by: Yuri Shkuro <ysh@meta.com>
Signed-off-by: Yuri Shkuro <ysh@meta.com>
Signed-off-by: Yuri Shkuro <ysh@meta.com>
The json-markup library does not properly escape the keys. Not clear if it is maintained or not, last changes were several years ago. Since it's just a single file, copy it directly and fix in place:
<a href="...">
date
type which will never be in the JSON that we obtain from span tags via JSON.parse()Add tests: