Skip to content

Version 1.1.2#12

Merged
JosunLP merged 5 commits intomainfrom
development
Jan 24, 2026
Merged

Version 1.1.2#12
JosunLP merged 5 commits intomainfrom
development

Conversation

@JosunLP
Copy link
Copy Markdown
Collaborator

@JosunLP JosunLP commented Jan 24, 2026

This pull request focuses on improving link security in the HTML sanitizer by automatically adding rel="noopener noreferrer" to external and target="_blank" links, updating documentation and tests accordingly, and making minor documentation and test improvements. These changes help prevent tabnabbing and referrer leakage vulnerabilities while ensuring the sanitizer's behavior is well-documented and robustly tested.

Security enhancements:

  • Added logic in sanitize.ts to automatically add rel="noopener noreferrer" to <a> tags that either have target="_blank" or point to external domains, including protocol-relative URLs and special protocols like mailto: and tel:. Existing rel values are preserved and merged. [1] [2]
  • Updated the set of allowed attributes in the sanitizer to include rel and target.

Documentation updates:

  • Updated CHANGELOG.md to document the security improvements and documentation fixes.
  • Expanded the security guide (docs/guide/security.md) with a new section on automatic link security, including code examples for various link scenarios.
  • Updated usage examples in README.md to demonstrate the new link security behavior.
  • Fixed import paths and improved error handling in the agents guide, and clarified backend call error handling. [1] [2] [3]

Testing improvements:

  • Added comprehensive tests to security.test.ts to cover the new link security behavior, including edge cases for various protocols, casing, whitespace, SSR/Node.js environments, and preservation of existing rel values.
  • Minor improvements to utility tests for reliability and coverage. [1] [2]

Version bump:

  • Bumped package version to 1.1.2 in package.json to reflect the new release.

Copilot AI and others added 4 commits January 24, 2026 01:20
test: improve utils test clarity and performance
* Initial plan

* Fix import paths and add error handling in agents.md documentation

Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>

* Complete: All fixes applied and verified

Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>

* Remove package-lock.json and add to gitignore

Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>

* Address PR review comments: add statusText and validate reply type

Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>

---------

Co-authored-by: Jonas Pfalzgraf <info@josunlp.de>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>
* Initial plan

* Add automatic rel="noopener noreferrer" to external links in sanitizer

Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>

* Update documentation for automatic link security feature

Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>

* Fix isExternalUrl for Node.js and protocol-relative URLs

Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>

* Handle special protocols and edge cases in rel attribute parsing

Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>

* Fix case-sensitivity and whitespace handling in URL checks

Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>

---------

Co-authored-by: Jonas Pfalzgraf <info@josunlp.de>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>
@JosunLP JosunLP self-assigned this Jan 24, 2026
Copilot AI review requested due to automatic review settings January 24, 2026 01:17
@JosunLP JosunLP added the bug Something isn't working label Jan 24, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR enhances link security in bQuery's HTML sanitizer by automatically adding rel="noopener noreferrer" to external and target="_blank" links to prevent tabnabbing and referrer leakage vulnerabilities. The changes include comprehensive test coverage and updated documentation across multiple guides.

Changes:

  • Added automatic rel="noopener noreferrer" to links with target="_blank" or external URLs in the sanitizer
  • Added comprehensive test coverage for the new link security feature with 102 new test lines covering edge cases
  • Fixed import paths in agents documentation and improved error handling examples
  • Updated security documentation with detailed examples of the new link security behavior

Reviewed changes

Copilot reviewed 8 out of 9 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/security/sanitize.ts Added isExternalUrl helper function and logic to automatically add rel="noopener noreferrer" to external/target="_blank" links; added rel and target to allowed attributes
tests/security.test.ts Added 102 lines of comprehensive tests covering link security behavior including edge cases for protocols, casing, whitespace, SSR environments, and rel preservation
tests/utils.test.ts Minor test improvements: renamed loop variable for clarity and added explicit assertion for prototype pollution test
docs/guide/security.md Added new "Automatic Link Security" section with detailed examples demonstrating the feature
docs/guide/agents.md Fixed import paths to use package-scoped imports and improved error handling in example code
README.md Added example demonstrating automatic link security feature
CHANGELOG.md Added version 1.1.2 entry documenting the security enhancement and documentation fixes
package.json Bumped version from 1.1.1 to 1.1.2
.gitignore Added package-lock.json to gitignore

Copy link
Copy Markdown
Contributor

Copilot AI commented Jan 24, 2026

@JosunLP I've opened a new pull request, #13, to work on those changes. Once the pull request is ready, I'll request review from you.

…13)

* Initial plan

* Add critical comment explaining protocol-relative URL check

Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>

* Update src/security/sanitize.ts

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>
Co-authored-by: Jonas Pfalzgraf <info@josunlp.de>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@JosunLP JosunLP merged commit c593231 into main Jan 24, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants