Skip to content

Commit

Permalink
Merge pull request #3982 from Countly/SER-531
Browse files Browse the repository at this point in the history
[SER-531] changes to fix events data not showing for &
  • Loading branch information
kanwarujjaval authored Feb 22, 2023
2 parents 6b926cd + 63367cf commit 9a08f0f
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 112 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -162,10 +162,10 @@
return obj;
},
decode: function(str) {
return str.replace(/^&#36;/g, "$").replace(/&#46;/g, '.').replace(/&lt;/g, '<').replace(/&gt;/g, '>').replace(/&le;/g, '<=').replace(/&ge;/g, '>=');
return str.replace(/&amp;/g, '&').replace(/^&#36;/g, "$").replace(/&#46;/g, '.').replace(/&lt;/g, '<').replace(/&gt;/g, '>').replace(/&le;/g, '<=').replace(/&ge;/g, '>=');
},
encode: function(str) {
return str.replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/<=/g, "&le;").replace(/>=/g, "&ge;");
return str.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/<=/g, "&le;").replace(/>=/g, "&ge;");
},
getEventLongName: function(eventKey, eventMap) {
var mapKey = eventKey.replace(/\\/g, "\\\\").replace(/\$/g, "\\u0024").replace(/\./g, "\\u002e");
Expand Down Expand Up @@ -795,34 +795,6 @@
return countlyAllEvents.service.fetchAllEventsData(context, period)
.then(function(res) {
if (res) {
//decoding html elements
res.list = res.list.map(function(val) {
return countlyCommon.unescapeHtml(val);
});
Object.keys(res.map).forEach(function(key) {
var decodedKey = countlyCommon.unescapeHtml(key);
if (res.map[key].name) {
res.map[key].name = countlyCommon.unescapeHtml(res.map[key].name);
}
if (res.map[key].key) {
res.map[key].key = countlyCommon.unescapeHtml(res.map[key].key);
}
if (res.map[key].description) {
res.map[key].description = countlyCommon.unescapeHtml(res.map[key].description);
}
if (key !== decodedKey) {
res.map[decodedKey] = res.map[key];
delete res.map[key];
}
});
Object.keys(res.segments).forEach(function(key) {
var decodedKey = countlyCommon.unescapeHtml(key);
if (key !== decodedKey) {
res.segments[decodedKey] = res.segments[key];
delete res.segments[key];
}
});

context.commit("setAllEventsData", res);
if (!context.state.selectedEventName) {
var appId = countlyCommon.ACTIVE_APP_ID;
Expand Down Expand Up @@ -851,13 +823,6 @@
countlyAllEvents.service.fetchSelectedEventsOverview(context, period)
.then(function(resp) {
if (resp) {
Object.keys(resp).forEach(function(key) {
var decodedKey = countlyCommon.unescapeHtml(key);
if (key !== decodedKey) {
resp[decodedKey] = resp[key];
delete resp[key];
}
});
context.commit("setSelectedEventsOverview", countlyAllEvents.helpers.getSelectedEventsOverview(context, resp) || {});
context.commit("setLegendData", countlyAllEvents.helpers.getSelectedEventsLegend(context, response));
context.dispatch('setTableLoading', false);
Expand Down Expand Up @@ -935,7 +900,7 @@
if (data) {
var map = {};
data.forEach(function(c) {
map[c._id] = countlyCommon.unescapeHtml(c.name);
map[c._id] = c.name;
});
context.commit('setCategoriesMap', map);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
},
decode: function(str) {
if (typeof str === 'string') {
return str.replace(/^&#36;/g, "$").replace(/&#46;/g, '.').replace(/&lt;/g, '<').replace(/&gt;/g, '>').replace(/&le;/g, '<=').replace(/&ge;/g, '>=');
return str.replace(/&amp;/g, '&').replace(/^&#36;/g, "$").replace(/&#46;/g, '.').replace(/&lt;/g, '<').replace(/&gt;/g, '>').replace(/&le;/g, '<=').replace(/&ge;/g, '>=');
}
return str;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -258,59 +258,6 @@
return eventKey;
}
},
formatEvents: function(res) {
//decoding html elements
res.list = res.list.map(function(val) {
return countlyCommon.unescapeHtml(val);
});
Object.keys(res.map).forEach(function(key) {
var decodedKey = countlyCommon.unescapeHtml(key);
if (res.map[key].name) {
res.map[key].name = countlyCommon.unescapeHtml(res.map[key].name);
}
if (res.map[key].key) {
res.map[key].key = countlyCommon.unescapeHtml(res.map[key].key);
}
if (res.map[key].description) {
res.map[key].description = countlyCommon.unescapeHtml(res.map[key].description);
}
if (key !== decodedKey) {
res.map[decodedKey] = res.map[key];
delete res.map[key];
}
});
Object.keys(res.segments).forEach(function(key) {
var decodedKey = countlyCommon.unescapeHtml(key);
if (res.segments[key].length) {
res.segments[key] = res.segments[key].map(function(val) {
if (val) {
val = countlyCommon.unescapeHtml(val);
}
return val;
});
}
if (key !== decodedKey) {
res.segments[decodedKey] = res.segments[key];
delete res.segments[key];
}
});
res.overview = res.overview.map(function(val) {
val.eventKey = countlyCommon.unescapeHtml(val.eventKey);
val.eventName = countlyCommon.unescapeHtml(val.eventName);
return val;
});
return res;
},
formatMonitorEvents: function(response) {
Object.keys(response).forEach(function(key) {
var decodedKey = countlyCommon.unescapeHtml(key);
if (key !== decodedKey) {
response[decodedKey] = response[key];
delete response[key];
}
});
return response;
}
};

countlyEventsOverview.service = {
Expand Down Expand Up @@ -444,7 +391,6 @@
return countlyEventsOverview.service.fetchMonitorEvents(context, period)
.then(function(res) {
if (res) {
res = countlyEventsOverview.helpers.formatEvents(res);
context.commit("setMonitorEvents", res || {});
var events = [];
if (res && res.overview) {
Expand All @@ -463,7 +409,6 @@
.then(function(response) {
context.dispatch("setMonitorEventsLoading", false);
if (response) {
response = countlyEventsOverview.helpers.formatMonitorEvents(response);
return context.commit("setMonitorEventsData", countlyEventsOverview.helpers.getMonitorEvents(response, context) || []);
}
});
Expand All @@ -472,14 +417,6 @@
countlyEventsOverview.service.fetchTopEvents("count", 3)
.then(function(resp) {
if (resp) {
if (resp.data.length) {
resp.data = resp.data.map(function(val) {
if (val.name) {
val.name = countlyCommon.unescapeHtml(val.name);
}
return val;
});
}
return context.commit("setTopEvents", countlyEventsOverview.helpers.getTopEvents(resp, res.map) || []);

}
Expand All @@ -491,14 +428,6 @@
.then(function(response) {
context.dispatch("setTableLoading", false);
if (response) {
if (response.data.length) {
response.data = response.data.map(function(val) {
if (val.name) {
val.name = countlyCommon.unescapeHtml(val.name);
}
return val;
});
}
context.commit("setDetailEvents", response || {});
context.commit("setEventOverview", countlyEventsOverview.helpers.getEventOverview(response) || []);
context.commit("setTableRows", countlyEventsOverview.helpers.getTableRows(response.data, res.map) || []);
Expand Down Expand Up @@ -534,7 +463,6 @@
return countlyEventsOverview.service.fetchMonitorEvents(context, period)
.then(function(res) {
if (res) {
res = countlyEventsOverview.helpers.formatEvents(res);
context.commit("setMonitorEvents", res || {});
var events = [];
if (res && res.overview) {
Expand All @@ -554,7 +482,6 @@
context.dispatch("setMonitorEventsLoading", false);

if (response) {
response = countlyEventsOverview.helpers.formatMonitorEvents(response);
return context.commit("setMonitorEventsData", countlyEventsOverview.helpers.getMonitorEvents(response, context) || []);
}
});
Expand Down

0 comments on commit 9a08f0f

Please sign in to comment.