diff options
| author | Alexander Pickering <alexandermpickering@gmail.com> | 2016-05-09 15:32:24 -0400 |
|---|---|---|
| committer | Alexander Pickering <alexandermpickering@gmail.com> | 2016-05-09 15:32:24 -0400 |
| commit | 08c9221ad098c14761324be9c941af84bc63ad79 (patch) | |
| tree | 2af4a9e1c2abf4742285d2c6a43919ee8fb34f16 /ws2a | |
| parent | dd2bb2f82f20eec33ebf99c81b61d213c91b299b (diff) | |
| download | webpage-08c9221ad098c14761324be9c941af84bc63ad79.tar.gz webpage-08c9221ad098c14761324be9c941af84bc63ad79.tar.bz2 webpage-08c9221ad098c14761324be9c941af84bc63ad79.zip | |
Moved html character escapeing to the server side
Diffstat (limited to 'ws2a')
| -rw-r--r-- | ws2a/bugsdata.c | 25 | ||||
| -rw-r--r-- | ws2a/bugsload.js | 12 |
2 files changed, 25 insertions, 12 deletions
diff --git a/ws2a/bugsdata.c b/ws2a/bugsdata.c index e587e4c..d04560e 100644 --- a/ws2a/bugsdata.c +++ b/ws2a/bugsdata.c @@ -56,9 +56,32 @@ void printbug(FILE* f){ if(part != 2){ printf("<td>"); } - } + }else if(c == "&"){ + printf("&"); + }else if(c == "\""){ + printf("""); + }else if(c == "'"){ + printf("'"); + }else if(c == "<"){ + printf("<"); + }else if(c == ">"){ + printf(">"); + }else if(c == "\\"){ + printf("/"); else{ putchar(c); } } } + +/* +function htmlEscape(str) { + return String(str) + .replace(/&/g, '&') + .replace(/"/g, '"') + .replace(/'/g, ''') + .replace(/</g, '<') + .replace(/>/g, '>') + .replace(/\//g, '/'); +} +*/ diff --git a/ws2a/bugsload.js b/ws2a/bugsload.js index 1212e15..4c8b007 100644 --- a/ws2a/bugsload.js +++ b/ws2a/bugsload.js @@ -1,18 +1,8 @@ -function htmlEscape(str) { - return String(str) - .replace(/&/g, '&') - .replace(/"/g, '"') - .replace(/'/g, ''') - .replace(/</g, '<') - .replace(/>/g, '>') - .replace(/\//g, '/'); -} - function loadLastBugs() { var xhttp = new XMLHttpRequest(); xhttp.onreadystatechange = function() { if (xhttp.readyState == 4 && xhttp.status == 200) { - document.getElementById("bugstable").innerHTML = htmlEscape(xhttp.responseText); + document.getElementById("bugstable").innerHTML = xhttp.responseText; } }; xhttp.open("GET", "/cgi-bin/bugsdata.cgi", true); |
