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

protect toString(hex) #770

Merged
merged 2 commits into from
Oct 19, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions lib/bindings/HTTPBinding.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,13 @@ function parseData(req, res, next) {
next(error);
} else {
req.jsonPayload = data;
// This is just for log data
if (req.body !== undefined) {
data = data.toString('hex');
try {
// This is just for log data
data = data.toString('hex');
} catch (e) {
// no error should be reported
}
}
config.getLogger().debug(context, 'Parsed data: %j', data);
next();
Expand Down Expand Up @@ -294,7 +298,11 @@ function handleIncomingMeasure(req, res, next) {

if (req.attr && req.jsonPayload) {
config.getLogger().debug(context, 'Parsing attr %s with value %s', req.attr, req.jsonPayload);
req.jsonPayload = req.jsonPayload.toString('hex');
try {
req.jsonPayload = req.jsonPayload.toString('hex');
} catch (e) {
// no error should be reported
}
const theAttr = [{ name: req.attr, value: req.jsonPayload, type: 'None' }];
attributeArr.push(theAttr);
} else {
Expand Down
Loading