Skip to content

fix: address underscore link parsing gap in #41727 - #41731

Open
AlgoArtist06 wants to merge 1 commit into
RocketChat:developfrom
AlgoArtist06:pr/41727-hyperlink-underscores-20260810
Open

fix: address underscore link parsing gap in #41727#41731
AlgoArtist06 wants to merge 1 commit into
RocketChat:developfrom
AlgoArtist06:pr/41727-hyperlink-underscores-20260810

Conversation

@AlgoArtist06

@AlgoArtist06 AlgoArtist06 commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Proposed changes (including videos or screenshots)

Prevents an unmatched underscore in Markdown link text from treating an underscore in the URL as its emphasis closer.

Adds the exact reported regression case and a patch changeset for @rocket.chat/message-parser.

This independently addresses the parser gap still present in #41727 while keeping the change scoped to the message parser.

Issue(s)

Fixes #41725

Related to #41727

Steps to test or reproduce

  1. Post [test-with-a-text-containing-an_here](http://example.com?param=my_value) in a channel.
  2. Confirm only test-with-a-text-containing-an_here is displayed and the whole label links to http://example.com?param=my_value.
  3. Run corepack yarn workspace @rocket.chat/message-parser test --runInBand with Node 22.22.3.

Further comments

Local verification:

  • Message parser tests: 36 suites passed, 719 tests passed.
  • Message parser lint: passed with 0 errors and 6 existing warnings.
  • Message parser typecheck: passed.
  • Message parser build: passed.

The full Rocket.Chat monorepo test suite was not run because it is impractical for this focused parser change.

Review in cubic

Summary by CodeRabbit

  • Bug Fixes

    • Fixed Markdown links so labels and URLs containing underscores are parsed and displayed correctly.
  • Tests

    • Added coverage for links containing hyphens and underscores.

@dionisio-bot

dionisio-bot Bot commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Looks like this PR is not ready to merge, because of the following issues:

  • This PR is missing the 'stat: QA assured' label
  • This PR is missing the required milestone or project

Please fix the issues and try again

If you have any trouble, please check the PR guidelines

@changeset-bot

changeset-bot Bot commented Aug 10, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: f4526e4

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@rocket.chat/message-parser Patch
@rocket.chat/gazzodown Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coderabbitai

coderabbitai Bot commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: b1fc5b51-8884-4762-9476-480b22eed3df

📥 Commits

Reviewing files that changed from the base of the PR and between 73b6281 and f4526e4.

📒 Files selected for processing (3)
  • .changeset/calm-links-render.md
  • packages/message-parser/src/grammar.pegjs
  • packages/message-parser/tests/link.test.ts
📜 Recent review details
🧰 Additional context used
📓 Path-based instructions (2)
**/*.{ts,tsx,js}

📄 CodeRabbit inference engine (.cursor/rules/playwright.mdc)

**/*.{ts,tsx,js}: Write concise, technical TypeScript/JavaScript with accurate typing in Playwright tests
Avoid code comments in the implementation

Files:

  • packages/message-parser/tests/link.test.ts
packages/**

📄 CodeRabbit inference engine (CLAUDE.md)

Shared libraries belong in packages/, while other services belong in apps/ and ee/.

Files:

  • packages/message-parser/tests/link.test.ts
  • packages/message-parser/src/grammar.pegjs
🧠 Learnings (4)
📚 Learning: 2026-03-16T21:50:37.589Z
Learnt from: amitb0ra
Repo: RocketChat/Rocket.Chat PR: 39676
File: .changeset/migrate-users-register-openapi.md:3-3
Timestamp: 2026-03-16T21:50:37.589Z
Learning: For changes related to OpenAPI migrations in Rocket.Chat/OpenAPI, when removing endpoint types and validators from rocket.chat/rest-typings (e.g., UserRegisterParamsPOST, /v1/users.register) document this as a minor changeset (not breaking) per RocketChat/Rocket.Chat-Open-API#150 Rule 7. Note that the endpoint type is re-exposed via a module augmentation .d.ts in the consuming package (e.g., packages/web-ui-registration/src/users-register.d.ts). In reviews, ensure the changeset clearly states: this is a non-breaking change, the major version should not be bumped, and the changeset reflects a minor version bump. Do not treat this as a breaking change during OpenAPI migrations.

Applied to files:

  • .changeset/calm-links-render.md
📚 Learning: 2026-02-26T19:25:44.063Z
Learnt from: gabriellsh
Repo: RocketChat/Rocket.Chat PR: 38778
File: packages/ui-voip/src/providers/useMediaSession.ts:192-192
Timestamp: 2026-02-26T19:25:44.063Z
Learning: In the Rocket.Chat repository, do not reference Biome lint rules in code review feedback. Biome is not used even if biome.json exists; only reference Biome rules if there is explicit, project-wide usage documented. For TypeScript files, review lint implications without Biome guidance unless the project enables Biome rules.

Applied to files:

  • packages/message-parser/tests/link.test.ts
📚 Learning: 2026-02-26T19:25:44.063Z
Learnt from: gabriellsh
Repo: RocketChat/Rocket.Chat PR: 38778
File: packages/ui-voip/src/providers/useMediaSession.ts:192-192
Timestamp: 2026-02-26T19:25:44.063Z
Learning: In this repository (RocketChat/Rocket.Chat), Biome lint rules are not used even if a biome.json exists. When reviewing TypeScript files (e.g., packages/ui-voip/src/providers/useMediaSession.ts), ensure lint suggestions do not reference Biome-specific rules. Rely on general ESLint/TypeScript lint rules and project conventions instead.

Applied to files:

  • packages/message-parser/tests/link.test.ts
📚 Learning: 2026-05-06T12:21:44.083Z
Learnt from: juliajforesti
Repo: RocketChat/Rocket.Chat PR: 40256
File: apps/meteor/client/components/CreateDiscussion/CreateDiscussion.tsx:121-149
Timestamp: 2026-05-06T12:21:44.083Z
Learning: Field wrappers in rocket.chat/fuselage-forms (Field, FieldLabel, FieldRow, FieldError, FieldHint) auto-create htmlFor/id associations, aria-describedby, and role="alert" for errors. Do not manually set htmlFor, id, aria-describedby, or role attributes when using these wrappers. This automatic wiring does not apply to plain rocket.chat/fuselage components, which require explicit ID wiring per the accessibility docs. In code reviews, prefer using fuselage-forms wrappers for form fields and verify there is no unnecessary manual ID/aria wiring in files that use these wrappers. If a component uses plain fuselage components, ensure proper id wiring as per docs.

Applied to files:

  • packages/message-parser/tests/link.test.ts
🔇 Additional comments (3)
packages/message-parser/src/grammar.pegjs (1)

393-394: LGTM!

packages/message-parser/tests/link.test.ts (1)

29-32: LGTM!

.changeset/calm-links-render.md (1)

1-5: LGTM!


Walkthrough

The message parser now preserves underscores in Markdown link labels when the URL also contains underscores. A parser test covers the link syntax, and a patch changeset documents the fix.

Changes

Message parser link fix

Layer / File(s) Summary
Link title parsing and validation
packages/message-parser/src/grammar.pegjs, packages/message-parser/tests/link.test.ts, .changeset/calm-links-render.md
LinkTitle handles the affected leading underscore pattern as plain text. The test verifies the complete link label and URL. The changeset records a patch release for @rocket.chat/message-parser.

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

Possibly related PRs

Suggested labels: type: bug

Suggested reviewers: ggazzo

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the underscore link-parsing fix addressed by the pull request.
Linked Issues check ✅ Passed The grammar fix and regression test address incorrect hyperlink rendering when both link text and URL contain underscores [#41725].
Out of Scope Changes check ✅ Passed The changeset, parser update, and regression test are all within the linked issue scope.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

Warning

Review ran into problems

🔥 Problems

Errors were encountered while retrieving linked issues.

Errors (1)
  • UNDERSCORES-20260810: Request failed with status code 401

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.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No issues found across 3 files

Re-trigger cubic

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Wrong display of hyperlinks when an underscore is present in the text

1 participant