Skip to content
Draft
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
26 changes: 13 additions & 13 deletions lib/data/odk-reporter.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,26 +24,26 @@ const convertObjectToXml = (data) => {
// and are XML-encoded for safety. Object keys are assumed safe and not encoded,
// as they are generated by the application, not users.

let output = '';
if (data == null) return '';

if (typeof data === 'object') {
for (const k in data) {
if (Object.hasOwn(data, k)) {
if (Array.isArray(data[k])) {
// If the data is an array, it is repeat data and
// the xml should have the outer tag repeated e.g.
// <projects><num_users>5</num_users></projects><projects><num_users>44</num_users></projects>
for (const repeat of data[k]) {
output = output.concat(`<${k}>`, convertObjectToXml(repeat), `</${k}>`);
}
} else {
output = output.concat(`<${k}>`, convertObjectToXml(data[k]), `</${k}>`);
let output = '';
for (const [k, v] of Object.entries(data)) {
if (Array.isArray(v)) {
// If the data is an array, it is repeat data and
// the xml should have the outer tag repeated e.g.
// <projects><num_users>5</num_users></projects><projects><num_users>44</num_users></projects>
for (const repeat of v) {
output = output.concat(`<${k}>`, convertObjectToXml(repeat), `</${k}>`);
}
} else {
output = output.concat(`<${k}>`, convertObjectToXml(v), `</${k}>`);
}
}
return output;
} else {
return encodeXML(String(data));
}
return output;
};

const buildSubmission = (formId, formVersion, data) => {
Expand Down