Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F32374949
D5715.1765327870.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
D5715.1765327870.diff
View Options
diff --git a/lib/shared/markdown.js b/lib/shared/markdown.js
--- a/lib/shared/markdown.js
+++ b/lib/shared/markdown.js
@@ -252,6 +252,10 @@
const spoilerRegex: RegExp = /^\|\|([^\n]+?)\|\|/g;
+function hideSpoilerText(text: string): string {
+ return text.replace(/\|\|(.+?)\|\|/g, '⬛⬛⬛');
+}
+
export {
paragraphRegex,
paragraphStripTrailingNewlineRegex,
@@ -272,4 +276,5 @@
matchList,
parseList,
matchMentions,
+ hideSpoilerText,
};
diff --git a/lib/shared/messages/text-message-spec.js b/lib/shared/messages/text-message-spec.js
--- a/lib/shared/messages/text-message-spec.js
+++ b/lib/shared/messages/text-message-spec.js
@@ -16,7 +16,7 @@
import type { NotifTexts } from '../../types/notif-types';
import type { ThreadInfo } from '../../types/thread-types';
import type { RelativeUserInfo } from '../../types/user-types';
-import { type ASTNode, type SingleASTNode } from '../markdown';
+import { type ASTNode, type SingleASTNode, hideSpoilerText } from '../markdown';
import { threadIsGroupChat } from '../thread-utils';
import { stringForUser } from '../user-utils';
import type {
@@ -84,9 +84,9 @@
messageTitle({ messageInfo, markdownRules }) {
const { text } = messageInfo;
+ const textWithoutSpoilers = hideSpoilerText(text);
const parser = SimpleMarkdown.parserFor(markdownRules);
- const ast = parser(text, { disableAutoBlockNewlines: true });
-
+ const ast = parser(textWithoutSpoilers, { disableAutoBlockNewlines: true });
return getFirstNonQuotedRawLine(ast).trim();
},
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Dec 10, 12:51 AM (10 h, 48 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5859359
Default Alt Text
D5715.1765327870.diff (1 KB)
Attached To
Mode
D5715: [lib] Prevent spoiler text from appearing in MessagePreview
Attached
Detach File
Event Timeline
Log In to Comment