in htmLEncode, only replace space with   on the last character in string

This commit is contained in:
Lisa Milne 2023-11-11 16:57:18 +10:00
parent c543504387
commit ac2f7f813d

View file

@ -1290,11 +1290,10 @@ clite.shell = {
clite.lib = {
// makes text html safe
htmlEncode:function(txt) {
return txt
.replace(/&/g, '&amp')
.replace(/>/g, '&gt')
.replace(/</g, '&lt')
.replace(/ /g, '&nbsp;');
var rtxt = txt.replace(/&/g, '&amp').replace(/>/g, '&gt').replace(/</g, '&lt');
if (rtxt.length > 0 && rtxt[rtxt.length-1])
return rtxt.substring(0,rtxt.length-1)+'&nbsp;';
return rtxt;
},
// returns the file name of a path /tmp/test/foo = foo
basename:function(txt) {