|
@@ -29,6 +29,15 @@ function escapeHTML(unsafe: string): StringLike {
|
|
|
);
|
|
|
}
|
|
|
|
|
|
+function unescapeHTML(safe: string): string {
|
|
|
+ return safe
|
|
|
+ .replace(/&/g, "&")
|
|
|
+ .replace(/</g, "<")
|
|
|
+ .replace(/>/g, ">")
|
|
|
+ .replace(/"/g, """)
|
|
|
+ .replace(/'/g, "'");
|
|
|
+}
|
|
|
+
|
|
|
function joinChildren(children: StringLike[]): SafeString {
|
|
|
return new SafeString(children
|
|
|
.map(child => typeof child === 'string' ? escapeHTML(child) : child)
|
|
@@ -250,7 +259,7 @@ export function timelineAsJSON(username: string, tweets: Tweet[]): string {
|
|
|
const html = joinChildren(children);
|
|
|
return {
|
|
|
id: tweet.id_str,
|
|
|
- title: tweet.full_text.split('\n')[0],
|
|
|
+ title: unescapeHTML(tweet.full_text.split('\n')[0]),
|
|
|
url: buildTwitterUrl(`/${tweet.user.screen_name}/status/${tweet.id_str}`),
|
|
|
content_html: html,
|
|
|
date_published: new Date(tweet.created_at).toISOString(),
|