Skip to content

Commit f9aed8f

Browse files
authored
fix: 正規化されていない状態のhashtagが連合されてきたhtmlに含まれているとhashtagが正しくhashtagに復元されない問題を修正 (misskey-dev#13733)
1 parent cd7f727 commit f9aed8f

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
- 鍵アカウントユーザーか
1616
- 「アカウントを見つけやすくする」が有効なユーザーか
1717
- Fix: Play作成時に設定した公開範囲が機能していない問題を修正
18+
- Fix: 正規化されていない状態のhashtagが連合されてきたhtmlに含まれているとhashtagが正しくhashtagに復元されない問題を修正
1819

1920
### Client
2021
- Feat: アップロードするファイルの名前をランダム文字列にできるように

packages/backend/src/core/MfmService.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { Window } from 'happy-dom';
1010
import { DI } from '@/di-symbols.js';
1111
import type { Config } from '@/config.js';
1212
import { intersperse } from '@/misc/prelude/array.js';
13+
import { normalizeForSearch } from '@/misc/normalize-for-search.js';
1314
import type { IMentionedRemoteUsers } from '@/models/Note.js';
1415
import { bindThis } from '@/decorators.js';
1516
import * as TreeAdapter from '../../node_modules/parse5/dist/tree-adapters/default.js';
@@ -33,6 +34,8 @@ export class MfmService {
3334
// some AP servers like Pixelfed use br tags as well as newlines
3435
html = html.replace(/<br\s?\/?>\r?\n/gi, '\n');
3536

37+
const normalizedHashtagNames = hashtagNames == null ? undefined : new Set<string>(hashtagNames.map(x => normalizeForSearch(x)));
38+
3639
const dom = parse5.parseFragment(html);
3740

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

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

0 commit comments

Comments
 (0)