mirror of
https://github.com/twisterarmy/twister-html.git
synced 2025-01-13 16:37:52 +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) {
|
||||
// posts without '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)))
|
||||
// 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 ((typeof post.userpost.msg !== 'string' || post.userpost.msg === '')
|
||||
&& (typeof post.userpost.rt !== 'object'
|
||||
|| typeof post.userpost.rt.msg !== 'string' || post.userpost.rt.msg === ''))
|
||||
return;
|
||||
|
||||
postToElem(post, 'original').hide().appendTo(elem).slideDown('fast');
|
||||
|
@ -60,7 +60,7 @@ function postToElem(post, kind, promoted) {
|
||||
if (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;
|
||||
if (userpost.msg) {
|
||||
username = userpost.n;
|
||||
@ -86,6 +86,8 @@ function postToElem(post, kind, promoted) {
|
||||
content_to_rt = $.toJSON(userpost);
|
||||
content_to_sigrt = post.sig_userpost;
|
||||
}
|
||||
if (typeof msg !== 'string')
|
||||
msg = '';
|
||||
|
||||
// Now create the html elements
|
||||
var elem = $.MAL.getPostTemplate().clone(true).appendTo(twister.html.detached);
|
||||
|
@ -347,8 +347,10 @@ function timelineChangedUser()
|
||||
}
|
||||
|
||||
function willBeHidden(post) {
|
||||
// posts without '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)))
|
||||
// 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 ((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;
|
||||
|
||||
if (post['userpost']['n'] === defaultScreenName)
|
||||
|
Loading…
Reference in New Issue
Block a user