Skip to content

Commit

Permalink
CLDR-17248 Measure vote timing; log times to console; refactor to use…
Browse files Browse the repository at this point in the history
… fetch

-Make cldrVote.CLDR_VOTE_DEBUG true; log times to console

-Refactor to use modern cldrAjax.doFetch instead of legacy cldrAjax.sendXhr

-Reduce very long functions and nested subroutines

-Sanitize error message with new method makeSafe to avoid security warning

-Comments
  • Loading branch information
btangmu committed Nov 22, 2023
1 parent 159f90a commit ba36c91
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion tools/cldr-apps/js/src/esm/cldrVote.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -214,14 +214,27 @@ function handleVoteErr(tr, message, button) {
"<td colspan='4'>" +
cldrStatus.stopIcon() +
" Could not check value. Try reloading the page.<br>" +
message +
makeSafe(message) +
"</td>";

Check warning

Code scanning / CodeQL

DOM text reinterpreted as HTML Medium

DOM text
is reinterpreted as HTML without escaping meta-characters.
cldrRetry.handleDisconnect("Error submitting a vote");
button.className = "ichoice-o";
button.checked = false;
cldrSurvey.hideLoader();
}

/**
* Avoid warning, "Directly writing error messages to a webpage without sanitization allows for a cross-site
* scripting vulnerability if parts of the error message can be influenced by a user."
*
* @param {String} s the raw string
* @returns the sanitized string
*/
function makeSafe(s) {
const div = document.createElement("div");
div.innerHTML = s;

Check warning

Code scanning / CodeQL

Exception text reinterpreted as HTML Medium

Exception text
is reinterpreted as HTML without escaping meta-characters.
Exception text
is reinterpreted as HTML without escaping meta-characters.
Exception text
is reinterpreted as HTML without escaping meta-characters.
Exception text
is reinterpreted as HTML without escaping meta-characters.
return div.textContent;
}

function logVote(rowHash, vHash, value) {
console.log(
"Vote for " +
Expand Down

0 comments on commit ba36c91

Please sign in to comment.