Bug Fix: slugifyLikeString skips sanitization due to unassigned replace() result

Aperta Adatta ai principianti
#6,782 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 4 giorni

@deepak0x ci sta già lavorando.

Dal 10/11/2025.

  • #6784 di @deepak0x — aperta

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
65/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Ferma
Stack tecnologico
typescript
Ambito
databases

Direzione di ricerca

Inizia in app/lib/database/utils.ts, all'interno di slugifyLikeString, e ispeziona i suoi chiamanti in app/lib/methods/search.ts e app/lib/methods/helpers/mergeSubscriptionsRooms.ts. Conferma in che modo il risultato ignorato di replace() influisce sulla generazione dello slug, quindi verifica che i caratteri speciali vengano sanificati prima che slugify() riceva il valore e che i siti di chiamata interessati continuino a comportarsi come previsto.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

🐛 bug
Describe the Bug

The function slugifyLikeString in app/lib/database/utils.ts (around line 14) contains a bug where the replace() result is not assigned or returned.
Because of this, the string sanitization step is effectively skipped, and the unsanitized string (which may contain special characters) is passed directly to slugify().

Steps to Reproduce

Open app/lib/database/utils.ts.

Locate the slugifyLikeString function (lines 12–17).

Notice this line:

str?.replace(likeStringRegex, '_');

The result of replace() is not assigned back to str or returned.

This means the sanitization step does not take effect before the string is passed to slugify().

Expected Behavior

The line should assign the result of replace() back to the variable:

str = str?.replace(likeStringRegex, '_') ?? str;

OR
chain the operation like this:

const sanitized = str.replace(likeStringRegex, '_');
const slugified = slugify(sanitized);
return slugified;

The string should always be sanitized before being passed to slugify().

Actual Behavior

The replace() on line 14 does nothing because its result is ignored.

The raw string with special characters is passed directly to slugify().

The sanitization step is effectively skipped.

Rocket.Chat Server Version

N/A (Code bug fix)

Rocket.Chat App Version

4.67.0

Device Name

N/A

OS Version

N/A

Additional Context

File: app/lib/database/utils.ts

Impact: The slugifyLikeString function is used in:

  • app/lib/methods/search.ts
  • app/lib/methods/helpers/mergeSubscriptionsRooms.ts

Note: This bug means special characters may not be properly sanitized before slugification, which could lead to unexpected behavior in search and room merging functionality.

Lingua principale
TypeScript
Stelle
2.4k
Fork
1.5k
Merge medio
5g 16h
PR unite (30g)
38

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di RocketChat/Rocket.Chat.ReactNative

Tutte le issue di RocketChat/Rocket.Chat.ReactNative

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.