Fossil SCM
chat: a proactive fix for a potential null deref. Documented a not-immediately-obvious element.
Commit
cdb8f6902f94aa811aaf75b3125e12d9606ee4db7b8ad41488aa320dd6f1cb93
Parent
a0ebe0ead1fa237…
1 file changed
+9
-2
+9
-2
| --- tools/chat.tcl | ||
| +++ tools/chat.tcl | ||
| @@ -49,11 +49,13 @@ | ||
| 49 | 49 | <input type="file" name="file"> |
| 50 | 50 | </div> |
| 51 | 51 | </div> |
| 52 | 52 | </form> |
| 53 | 53 | <hr> |
| 54 | - <span id='message-inject-point'></span> | |
| 54 | + <span id='message-inject-point'><!-- | |
| 55 | + new chat messages get inserted immediately after this element | |
| 56 | + --></span> | |
| 55 | 57 | |
| 56 | 58 | </div><!-- .fossil-doc --> |
| 57 | 59 | <hr> |
| 58 | 60 | <p> |
| 59 | 61 | <a href="chat/env">CGI environment</a> | |
| @@ -239,15 +241,20 @@ | ||
| 239 | 241 | span.appendChild(e); |
| 240 | 242 | }); |
| 241 | 243 | //console.debug("span =",span.innerHTML); |
| 242 | 244 | return span; |
| 243 | 245 | }/*end messageToDOM()*/; |
| 246 | + /* Injects element e as a new row in the chat, at the top of the list */ | |
| 244 | 247 | const injectMessage = function f(e){ |
| 245 | 248 | if(!f.injectPoint){ |
| 246 | 249 | f.injectPoint = document.querySelector('#message-inject-point'); |
| 247 | 250 | } |
| 248 | - f.injectPoint.parentNode.insertBefore(e, f.injectPoint.nextSibling); | |
| 251 | + if(f.injectPoint.nextSibling){ | |
| 252 | + f.injectPoint.parentNode.insertBefore(e, f.injectPoint.nextSibling); | |
| 253 | + }else{ | |
| 254 | + f.injectPoint.parentNode.appendChild(e); | |
| 255 | + } | |
| 249 | 256 | }; |
| 250 | 257 | function newcontent(jx){ |
| 251 | 258 | var i; |
| 252 | 259 | for(i=0; i<jx.msgs.length; ++i){ |
| 253 | 260 | let m = jx.msgs[i]; |
| 254 | 261 |
| --- tools/chat.tcl | |
| +++ tools/chat.tcl | |
| @@ -49,11 +49,13 @@ | |
| 49 | <input type="file" name="file"> |
| 50 | </div> |
| 51 | </div> |
| 52 | </form> |
| 53 | <hr> |
| 54 | <span id='message-inject-point'></span> |
| 55 | |
| 56 | </div><!-- .fossil-doc --> |
| 57 | <hr> |
| 58 | <p> |
| 59 | <a href="chat/env">CGI environment</a> | |
| @@ -239,15 +241,20 @@ | |
| 239 | span.appendChild(e); |
| 240 | }); |
| 241 | //console.debug("span =",span.innerHTML); |
| 242 | return span; |
| 243 | }/*end messageToDOM()*/; |
| 244 | const injectMessage = function f(e){ |
| 245 | if(!f.injectPoint){ |
| 246 | f.injectPoint = document.querySelector('#message-inject-point'); |
| 247 | } |
| 248 | f.injectPoint.parentNode.insertBefore(e, f.injectPoint.nextSibling); |
| 249 | }; |
| 250 | function newcontent(jx){ |
| 251 | var i; |
| 252 | for(i=0; i<jx.msgs.length; ++i){ |
| 253 | let m = jx.msgs[i]; |
| 254 |
| --- tools/chat.tcl | |
| +++ tools/chat.tcl | |
| @@ -49,11 +49,13 @@ | |
| 49 | <input type="file" name="file"> |
| 50 | </div> |
| 51 | </div> |
| 52 | </form> |
| 53 | <hr> |
| 54 | <span id='message-inject-point'><!-- |
| 55 | new chat messages get inserted immediately after this element |
| 56 | --></span> |
| 57 | |
| 58 | </div><!-- .fossil-doc --> |
| 59 | <hr> |
| 60 | <p> |
| 61 | <a href="chat/env">CGI environment</a> | |
| @@ -239,15 +241,20 @@ | |
| 241 | span.appendChild(e); |
| 242 | }); |
| 243 | //console.debug("span =",span.innerHTML); |
| 244 | return span; |
| 245 | }/*end messageToDOM()*/; |
| 246 | /* Injects element e as a new row in the chat, at the top of the list */ |
| 247 | const injectMessage = function f(e){ |
| 248 | if(!f.injectPoint){ |
| 249 | f.injectPoint = document.querySelector('#message-inject-point'); |
| 250 | } |
| 251 | if(f.injectPoint.nextSibling){ |
| 252 | f.injectPoint.parentNode.insertBefore(e, f.injectPoint.nextSibling); |
| 253 | }else{ |
| 254 | f.injectPoint.parentNode.appendChild(e); |
| 255 | } |
| 256 | }; |
| 257 | function newcontent(jx){ |
| 258 | var i; |
| 259 | for(i=0; i<jx.msgs.length; ++i){ |
| 260 | let m = jx.msgs[i]; |
| 261 |