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

Abierto Apto para principiantes
#6,782 1 comentario 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 4 días

@deepak0x ya está trabajando en esto.

Desde el 10/11/2025.

  • #6784 de @deepak0x — abierto

Evaluación

Dificultad
2/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
65/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Estancado
Stack tecnológico
typescript
Área
databases

Línea de trabajo

Comienza en app/lib/database/utils.ts, en slugifyLikeString, e inspecciona sus llamadas en app/lib/methods/search.ts y app/lib/methods/helpers/mergeSubscriptionsRooms.ts. Confirma cómo afecta a la generación del slug el resultado ignorado de replace() y verifica después que los caracteres especiales se saneen antes de que slugify() reciba el valor y que los puntos de llamada afectados sigan comportándose como se espera.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

🐛 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.

Lenguaje dominante
TypeScript
Estrellas
2.4k
Forks
1.5k
Merge medio
5 d 16 h
PR fusionados (30 d)
38

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de RocketChat/Rocket.Chat.ReactNative

Todos los issues de RocketChat/Rocket.Chat.ReactNative

Issues similares

Más issues de TypeScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.