mirror of
https://github.com/twisterarmy/twister-html.git
synced 2025-01-14 08:58:05 +00:00
add more strict checks for twist .msg fields corectness
This commit is contained in:
parent
e5a8c44d11
commit
2a37be1a73
@ -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');
|
||||||
|
@ -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);
|
||||||
|
@ -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…
Reference in New Issue
Block a user