Commas in post titles cause notification text to get truncated
-
-
@julianlam it happened again
-
I'll use an Oxford comma next time. Promise.
-
how
-
BTW, no repro..
-
@doctorjones said in Commas in post titles cause notification text to get truncated:
Actually, I'm not sure it's as simple as the topic title suggests..
-
@pjh it's probably something specific to the "
username
has posted a new topic:topictitle
" message.
-
@doctorjones said in Commas in post titles cause notification text to get truncated:
@pjh it's probably something specific to the "
username
has posted a new topic:topictitle
" message.I can't see anything obvious in source..
Warning - javascript ahead
pjh@hpdesktop:~/src$ grep "has posted a new topic" NodeBB/ -rBB/ -r NodeBB/public/language/bn/notifications.json: "user_posted_topic": "<strong>%1</strong> has posted a new topic: <strong>%2</strong>", [...]
pjh@hpdesktop:~/src$ grep user_posted_topic NodeBB/ -rB7 NodeBB/src/user/notifications.js- var title = topicData.title; NodeBB/src/user/notifications.js- if (title) { NodeBB/src/user/notifications.js- title = utils.decodeHTMLEntities(title); NodeBB/src/user/notifications.js- } NodeBB/src/user/notifications.js- NodeBB/src/user/notifications.js- notifications.create({ NodeBB/src/user/notifications.js- type: 'new-topic', NodeBB/src/user/notifications.js: bodyShort: '[[notifications:user_posted_topic, ' + postData.user.username + ', ' + title + ']]',
pjh@hpdesktop:~/src$ grep decodeHTMLEntities NodeBB/public/src/utils.js -A20 decodeHTMLEntities: function (html) { return String(html) .replace(/&#(\d+);?/g, function (_, code) { return String.fromCharCode(code); }) .replace(/&#[xX]([A-Fa-f0-9]+);?/g, function (_, hex) { return String.fromCharCode(parseInt(hex, 16)); }) .replace(/&([^;\W]+;?)/g, function (m, e) { var ee = e.replace(/;$/, ''); var target = HTMLEntities[e] || (e.match(/;$/) && HTMLEntities[ee]); if (typeof target === 'number') { return String.fromCharCode(target); } else if (typeof target === 'string') { return target; } return m; }); },
-
@pjh said in Commas in post titles cause notification text to get truncated:
I can't see anything obvious in source..
Or maybe...
NodeBB/src/user/notifications.js: bodyShort: '[[notifications:user_posted_topic, ' + postData.user.username + ', ' + title + ']]',
I think commas in
title
there would render anything after the first, something expected to populate a%3
and a%4
...I can't find anything similar to compare it with, that works, to see how it's dealt with. Nearest is..
pjh@hpdesktop:~/src$ grep upvoted_your_post NodeBB/src/socket.io/posts/votes.js -B5 -A5 }, ], callback); }; SocketPosts.upvote = function (socket, data, callback) { helpers.postCommand(socket, 'upvote', 'voted', 'notifications:upvoted_your_post_in', data, callback); }; SocketPosts.downvote = function (socket, data, callback) { helpers.postCommand(socket, 'downvote', 'voted', '', data, callback); };