Skip to content

Commit

Permalink
fix: 正規化されていない状態のhashtagが連合されてきたhtmlに含まれているとhashtagが正しくhashtagに復元されない…
Browse files Browse the repository at this point in the history
…問題を修正 (#13733)
  • Loading branch information
anatawa12 authored Apr 19, 2024
1 parent cd7f727 commit f9aed8f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
- 鍵アカウントユーザーか
- 「アカウントを見つけやすくする」が有効なユーザーか
- Fix: Play作成時に設定した公開範囲が機能していない問題を修正
- Fix: 正規化されていない状態のhashtagが連合されてきたhtmlに含まれているとhashtagが正しくhashtagに復元されない問題を修正

### Client
- Feat: アップロードするファイルの名前をランダム文字列にできるように
Expand Down
5 changes: 4 additions & 1 deletion packages/backend/src/core/MfmService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { Window } from 'happy-dom';
import { DI } from '@/di-symbols.js';
import type { Config } from '@/config.js';
import { intersperse } from '@/misc/prelude/array.js';
import { normalizeForSearch } from '@/misc/normalize-for-search.js';
import type { IMentionedRemoteUsers } from '@/models/Note.js';
import { bindThis } from '@/decorators.js';
import * as TreeAdapter from '../../node_modules/parse5/dist/tree-adapters/default.js';
Expand All @@ -33,6 +34,8 @@ export class MfmService {
// some AP servers like Pixelfed use br tags as well as newlines
html = html.replace(/<br\s?\/?>\r?\n/gi, '\n');

const normalizedHashtagNames = hashtagNames == null ? undefined : new Set<string>(hashtagNames.map(x => normalizeForSearch(x)));

const dom = parse5.parseFragment(html);

let text = '';
Expand Down Expand Up @@ -85,7 +88,7 @@ export class MfmService {
const href = node.attrs.find(x => x.name === 'href');

// ハッシュタグ
if (hashtagNames && href && hashtagNames.map(x => x.toLowerCase()).includes(txt.toLowerCase())) {
if (normalizedHashtagNames && href && normalizedHashtagNames.has(normalizeForSearch(txt))) {
text += txt;
// メンション
} else if (txt.startsWith('@') && !(rel && rel.value.startsWith('me '))) {
Expand Down

0 comments on commit f9aed8f

Please sign in to comment.