Skip to content

Conversation

@nvborisenko
Copy link
Member

Fix build warnings.

💥 What does this PR do?

This pull request makes a minor update to the ProtocolDefinitionItem class to improve how special characters are handled in descriptions.

  • Improved HTML encoding in the Description property by also replacing & with &amp; in addition to < and >, ensuring better safety and correctness in rendered output.

🔄 Types of changes

  • Bug fix (backwards compatible)

Copilot AI review requested due to automatic review settings February 10, 2026 21:07
@qodo-code-review
Copy link
Contributor

PR Type

Bug fix


Description

  • Fix HTML encoding in DevTools documentation by adding ampersand replacement

  • Prevent malformed XML/HTML in generated inline documentation

  • Improve special character handling in ProtocolDefinitionItem descriptions


File Walkthrough

Relevant files
Bug fix
ProtocolDefinitionItem.cs
Add ampersand HTML encoding to Description property           

third_party/dotnet/devtools/src/generator/ProtocolDefinition/ProtocolDefinitionItem.cs

  • Added .Replace("&", "&") to the Description property getter
  • Ensures ampersands are properly HTML-encoded alongside existing < and >
    replacements
  • Prevents XML/HTML parsing issues in generated documentation
  • Reformatted chained Replace calls for better readability
+4/-1     

@qodo-code-review
Copy link
Contributor

qodo-code-review bot commented Feb 10, 2026

PR Compliance Guide 🔍

Below is a summary of compliance checks for this PR:

Security Compliance
🟢
No security concerns identified No security vulnerabilities detected by AI analysis. Human verification advised for critical code.
Ticket Compliance
🎫 No ticket provided
  • Create ticket/issue
Codebase Duplication Compliance
Codebase context is not defined

Follow the guide to enable codebase context checks.

Custom Compliance
🟢
Generic: Comprehensive Audit Trails

Objective: To create a detailed and reliable record of critical system actions for security analysis
and compliance.

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Meaningful Naming and Self-Documenting Code

Objective: Ensure all identifiers clearly express their purpose and intent, making code
self-documenting

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Secure Error Handling

Objective: To prevent the leakage of sensitive system information through error messages while
providing sufficient detail for internal debugging.

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Secure Logging Practices

Objective: To ensure logs are useful for debugging and auditing without exposing sensitive
information like PII, PHI, or cardholder data.

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

🔴
Generic: Robust Error Handling and Edge Case Management

Objective: Ensure comprehensive error handling that provides meaningful context and graceful
degradation

Status:
Incorrect encoding order: The new replacement chain encodes & after converting </> to &lt;/&gt;,
causing double-encoding (e.g., &lt; becomes &amp;lt;) and incorrect output for
common edge cases.

Referred Code
get => InitialDescription?
    .Replace("<", "&lt;")
    .Replace(">", "&gt;")
    .Replace("&", "&amp;");

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Security-First Input Validation and Data Handling

Objective: Ensure all data inputs are validated, sanitized, and handled securely to prevent
vulnerabilities

Status:
Broken HTML sanitization: The manual HTML encoding is implemented in an unsafe order (& encoded last), resulting
in double-encoding and incorrect sanitization of user-controlled content in Description.

Referred Code
get => InitialDescription?
    .Replace("<", "&lt;")
    .Replace(">", "&gt;")
    .Replace("&", "&amp;");

Learn more about managing compliance generic rules or creating your own custom rules

  • Update
Compliance status legend 🟢 - Fully Compliant
🟡 - Partial Compliant
🔴 - Not Compliant
⚪ - Requires Further Human Verification
🏷️ - Compliance label

@selenium-ci selenium-ci added the B-devtools Includes everything BiDi or Chrome DevTools related label Feb 10, 2026
@qodo-code-review
Copy link
Contributor

qodo-code-review bot commented Feb 10, 2026

PR Code Suggestions ✨

Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Impact
Possible issue
Fix HTML entity encoding order
Suggestion Impact:The commit reordered the Replace calls to encode '&' first and removed the trailing ampersand replacement, addressing the double-encoding issue.

code diff:

             get => InitialDescription?
+                .Replace("&", "&amp;")
                 .Replace("<", "&lt;")
-                .Replace(">", "&gt;")
-                .Replace("&", "&amp;");
+                .Replace(">", "&gt;");

Fix a double-encoding bug by reordering the Replace method calls. The ampersand
character & should be replaced first.

third_party/dotnet/devtools/src/generator/ProtocolDefinition/ProtocolDefinitionItem.cs [14-17]

 get => InitialDescription?
+    .Replace("&", "&amp;")
     .Replace("<", "&lt;")
-    .Replace(">", "&gt;")
-    .Replace("&", "&amp;");
+    .Replace(">", "&gt;");

[Suggestion processed]

Suggestion importance[1-10]: 8

__

Why: The suggestion correctly identifies a bug in the PR where replacing & after other entities causes double-encoding, and provides a correct fix by reordering the Replace calls.

Medium
  • Update

Copy link
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 aims to fix build warnings and improve correctness of generated .NET DevTools inline documentation by ensuring special characters in protocol descriptions are properly escaped.

Changes:

  • Updated ProtocolDefinitionItem.Description escaping to additionally handle & characters.
  • Reformatted the Description getter into a multi-line chained replacement for readability.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings February 10, 2026 21:15
Copy link
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

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.

@nvborisenko nvborisenko merged commit 5bf0c7d into SeleniumHQ:trunk Feb 10, 2026
25 checks passed
@nvborisenko nvborisenko deleted the dotnet-fix-devtools-xml branch February 10, 2026 21:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

B-devtools Includes everything BiDi or Chrome DevTools related Review effort 1/5

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants