From 66cdccf008ca3dc7c1928ebceb35cedaab5bd704 Mon Sep 17 00:00:00 2001 From: acanas Date: Thu, 21 May 2020 12:30:08 +0200 Subject: [PATCH] Version19.239.6 --- js/{swad19.239.5.js => swad19.239.6.js} | 55 +++++++++++++------------ swad_changelog.h | 5 ++- 2 files changed, 32 insertions(+), 28 deletions(-) rename js/{swad19.239.5.js => swad19.239.6.js} (97%) diff --git a/js/swad19.239.5.js b/js/swad19.239.6.js similarity index 97% rename from js/swad19.239.5.js rename to js/swad19.239.6.js index 747e0083c..f9ba462e5 100644 --- a/js/swad19.239.5.js +++ b/js/swad19.239.6.js @@ -628,47 +628,50 @@ function updateExamPrint (idDiv,idInput,nameInput,Params,timeoutMsg) { } } -// Escape except - _ . ! ~ * ' ( ) // Escape the same chars as encodeURIComponent(), but in ISO-8859-1 function getEscapedString (str) { + const len = str.length; var escaped = ''; - for (var i = 0; i < str.length; i++) { + for (var i = 0; i < len; i++) { const code = str.charCodeAt(i); - var esc; - - switch (true) { - case (code < 16): - esc = '%0' + code.toString(16).toUpperCase(); // %0X + switch (true) { // Escape punctuation marks except - _ . ! ~ * ' ( ) + case (code <= 0x09): // Spec. + escaped += '%0' + code.toString(16).toUpperCase(); // %0X break; - case (code >= 16 && code <= 32): - case (code >= 34 && code <= 38): - case (code == 43): // '+' - case (code == 44): // ',' - case (code == 47): // '/' - case (code >= 58 && code <= 64): - case (code >= 91 && code <= 94): - case (code == 96): // '`' - case (code >= 123 && code <= 125): - case (code >= 127 && code <= 255): - esc = '%' + code.toString(16).toUpperCase(); // %XX + case (code >= 0x10 && code <= 0x20): // Spec. 0x20 space + case (code >= 0x22 && code <= 0x26): // 0x22 " 0x23 # 0x24 $ 0x25 % 0x26 & + case (code == 0x2B): // 0x2B + + case (code == 0x2C): // 0x2C , + case (code == 0x2F): // 0x2F / + case (code >= 0x3A && code <= 0x40): // 0x3A : 0x3B ; 0x3C < 0x3D = 0x3E > 0x3F ? 0x40 @ + case (code >= 0x5B && code <= 0x5E): // 0x5B [ 0x5C \ 0x5D ] 0x5E ^ + case (code == 0x60): // 0x60 ` + case (code >= 0x7B && code <= 0x7D): // 0x7B { 0x7C | 0x7D } + case (code >= 0x7F && code <= 0xFF): // ISO-8859-1 or windows-1252 + escaped += '%' + code.toString(16).toUpperCase(); // %XX break; - case (code >= 256): - esc = '%26%23' + code.toString(10) + '%3B'; // &#code; instead of %uXXXX + case (code >= 0x100): + escaped += '%26%23' + code.toString(10) + '%3B'; // &#code; instead of %uXXXX break; - default: - esc = str.charAt(i); + default: // 0x21 ! + // 0x27 ' 0x28 ( 0x29 ) 0x2A * + // 0x2D - 0x2E . + // 0x30 0 ... 0x39 9 + // 0x41 A ... 0x5A Z + // 0x5F _ + // 0x61 a ... 0x7A z + // 0x7E ~ + escaped += str.charAt(i); break; } - escaped += esc; } - return escaped; } /* -// To generate a table with the codification generated by escape() -// Copy the following code in https://playcode.io/ +// To generate a table with the codification generated by encodeURIComponent() +// and escape(), copy the following code in https://playcode.io/ //----------------------------------------------------------------------------- var arr = []; for(var i=0;i<256;i++) { diff --git a/swad_changelog.h b/swad_changelog.h index 863dea108..7f56b56ef 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -557,10 +557,11 @@ enscript -2 --landscape --color --file-align=2 --highlight --line-numbers -o - * En OpenSWAD: ps2pdf source.ps destination.pdf */ -#define Log_PLATFORM_VERSION "SWAD 19.239.5 (2020-05-21)" +#define Log_PLATFORM_VERSION "SWAD 19.239.6 (2020-05-21)" #define CSS_FILE "swad19.238.2.css" -#define JS_FILE "swad19.239.5.js" +#define JS_FILE "swad19.239.6.js" /* + Version 19.239.6: May 21, 2020 Code refactoring in JS function to escape chars. (301411 lines) Version 19.239.5: May 21, 2020 Fixed bug in charset in answer forms in exam prints. (301405 lines) Version 19.239.4: May 20, 2020 Fixed bug listing user's exam prints. (301332 lines) Version 19.239.3: May 20, 2020 Fixed bugs removing exam prints in a course.