Skip to content

fix(utils): harden removeChars default char set#833

Open
Garfield-fr wants to merge 1 commit into
rero:stagingfrom
Garfield-fr:zub-remove-chars-improvement
Open

fix(utils): harden removeChars default char set#833
Garfield-fr wants to merge 1 commit into
rero:stagingfrom
Garfield-fr:zub-remove-chars-improvement

Conversation

@Garfield-fr

Copy link
Copy Markdown
Contributor
  • Add "(", ")" and "" to the default removed chars, since they can break the query string structure built around user input
  • Escape each char before building the RegExp, since "" was previously unsafe to pass in
  • Keep other ES/Lucene operators (:, +, -, *) untouched by default

@Garfield-fr Garfield-fr self-assigned this Jul 20, 2026
@coderabbitai

coderabbitai Bot commented Jul 20, 2026

Copy link
Copy Markdown

Review Change Stack

Walkthrough

The removeChars utility now removes double quotes, parentheses, and backslashes by default. Configured characters are escaped before constructing the regular expression so they are treated literally. Unit tests cover default removal of parentheses and backslashes, while confirming Elasticsearch operator-like tokens remain unchanged.

Estimated code review effort: 2 (Simple) | ~10 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly matches the main change: hardening removeChars by expanding its default character set.
Description check ✅ Passed The description accurately describes the removeChars behavior change and regex escaping update.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint install timed out. The project may have too many dependencies for the sandbox.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@projects/rero/ng-core/src/lib/core/utils/utils.ts`:
- Around line 37-39: Update removeChars so its character escaping also escapes
hyphens before joining the escaped values into the RegExp character class,
ensuring custom sets remove only literal '-' characters. Add a regression test
covering a custom chars array containing '-' and verify range-like characters
remain unaffected.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 9deb1bde-0477-4ba2-85d5-06434f99959e

📥 Commits

Reviewing files that changed from the base of the PR and between 621e9bd and c876f1f.

📒 Files selected for processing (2)
  • projects/rero/ng-core/src/lib/core/utils/utils.spec.ts
  • projects/rero/ng-core/src/lib/core/utils/utils.ts

Comment thread projects/rero/ng-core/src/lib/core/utils/utils.ts
* Add "(", ")" and "\" to the default removed
  chars, since they can break the query string
  structure built around user input
* Escape each char before building the RegExp,
  since "\" was previously unsafe to pass in
* Keep other ES/Lucene operators (:, +, -, *)
  untouched by default

Co-Authored-by: Bertrand Zuchuat <bertrand.zuchuat@rero.ch>
@Garfield-fr
Garfield-fr force-pushed the zub-remove-chars-improvement branch from c876f1f to 3619642 Compare July 20, 2026 08:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants