Browse Source

add more strict checks for twist .msg fields corectness

readme-update
Simon Grim 9 years ago
parent
commit
2a37be1a73
  1. 6
      js/twister_actions.js
  2. 4
      js/twister_formatpost.js
  3. 6
      js/twister_timeline.js

6
js/twister_actions.js

@ -157,8 +157,10 @@ function requestRTs(postLi)
} }
function appendPostToElem(post, elem) { function appendPostToElem(post, elem) {
// posts without 'msg' and 'rt.msg' may be used for metadata like 'url' and are not meant to be displayed // posts without non-empty strings in both 'msg' and 'rt.msg' may be used for metadata like 'url' and are not meant to be displayed
if (!post.userpost.msg && (!post.userpost.rt || (post.userpost.rt && !post.userpost.rt.msg))) if ((typeof post.userpost.msg !== 'string' || post.userpost.msg === '')
&& (typeof post.userpost.rt !== 'object'
|| typeof post.userpost.rt.msg !== 'string' || post.userpost.rt.msg === ''))
return; return;
postToElem(post, 'original').hide().appendTo(elem).slideDown('fast'); postToElem(post, 'original').hide().appendTo(elem).slideDown('fast');

4
js/twister_formatpost.js

@ -60,7 +60,7 @@ function postToElem(post, kind, promoted) {
if (post.sig_wort) if (post.sig_wort)
userpost.sig_wort = post.sig_wort; userpost.sig_wort = post.sig_wort;
if (userpost.rt && userpost.rt.msg) { if (userpost.rt && typeof userpost.rt.msg === 'string' && userpost.rt.msg !== '') {
rt = userpost.rt; rt = userpost.rt;
if (userpost.msg) { if (userpost.msg) {
username = userpost.n; username = userpost.n;
@ -86,6 +86,8 @@ function postToElem(post, kind, promoted) {
content_to_rt = $.toJSON(userpost); content_to_rt = $.toJSON(userpost);
content_to_sigrt = post.sig_userpost; content_to_sigrt = post.sig_userpost;
} }
if (typeof msg !== 'string')
msg = '';
// Now create the html elements // Now create the html elements
var elem = $.MAL.getPostTemplate().clone(true).appendTo(twister.html.detached); var elem = $.MAL.getPostTemplate().clone(true).appendTo(twister.html.detached);

6
js/twister_timeline.js

@ -347,8 +347,10 @@ function timelineChangedUser()
} }
function willBeHidden(post) { function willBeHidden(post) {
// posts without 'msg' and 'rt.msg' may be used for metadata like 'url' and are not meant to be displayed // posts without non-empty strings in both 'msg' and 'rt.msg' may be used for metadata like 'url' and are not meant to be displayed
if (!post.userpost.msg && (!post.userpost.rt || (post.userpost.rt && !post.userpost.rt.msg))) if ((typeof post.userpost.msg !== 'string' || post.userpost.msg === '')
&& (typeof post.userpost.rt !== 'object'
|| typeof post.userpost.rt.msg !== 'string' || post.userpost.rt.msg === ''))
return true; return true;
if (post['userpost']['n'] === defaultScreenName) if (post['userpost']['n'] === defaultScreenName)

Loading…
Cancel
Save