Skip to content

Fix lengths of interpreted HTML special-character entities#56

Open
jgoossen851 wants to merge 4 commits intoZZJHONS:masterfrom
jgoossen851:bugfix/html-entity-lengths
Open

Fix lengths of interpreted HTML special-character entities#56
jgoossen851 wants to merge 4 commits intoZZJHONS:masterfrom
jgoossen851:bugfix/html-entity-lengths

Conversation

@jgoossen851
Copy link

Previously, the closing semicolon was not being removed from the interpreted string, causing ' to be replaced by '; instead of '. A similar error appeared for the double-quote ".

Previously, the closing semicolon was not being removed from the interpreted string, causing `'` to be replaced by `';` instead of `'`.
A similar error appeared for the double-quote `"`.
@gemini-code-assist
Copy link

Summary of Changes

Hello @jgoossen851, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request resolves a bug in the HTML entity decoding logic where specific character entities, namely " and ', were not being fully processed. The fix ensures that the trailing semicolon for these entities is correctly accounted for and removed, preventing malformed output and ensuring accurate string representation after decoding.

Highlights

  • HTML Entity Decoding Fix: Corrected the length calculation for " (double quote) and ' (apostrophe) HTML entities within the xmlDecodeEscapeString function. Previously, the closing semicolon was not being removed, leading to incorrect string interpretation.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request correctly fixes a bug in HTML entity decoding where &quot; and &apos; were not fully consumed, leading to an extra semicolon in the output. The lengths for these entities in ccStrCmpSeq calls and the corresponding skip values have been corrected. I've added a couple of suggestions to replace the magic numbers for lengths with sizeof(...) - 1 to improve code maintainability and prevent similar issues in the future.

bsx.c Outdated
Comment on lines +264 to +267
else if( ccStrCmpSeq( string, "quot;", 5 ) )
{
*dst++ = '"';
skip = 4;
skip = 5;

Choose a reason for hiding this comment

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

medium

While the fix is correct, using sizeof("quot;") - 1 instead of the magic number 5 would make the code more robust and maintainable. This avoids potential mismatches between the string literal and its length, which was the source of the original bug.

      else if( ccStrCmpSeq( string, "quot;", sizeof("quot;") - 1 ) )
      {
        *dst++ = '"';
        skip = sizeof("quot;") - 1;

bsx.c Outdated
Comment on lines +274 to +277
else if( ccStrCmpSeq( string, "apos;", 5 ) )
{
*dst++ = '\'';
skip = 4;
skip = 5;

Choose a reason for hiding this comment

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

medium

Similarly here, using sizeof("apos;") - 1 instead of the magic number 5 improves robustness and maintainability. This ensures the length always matches the string literal.

      else if( ccStrCmpSeq( string, "apos;", sizeof("apos;") - 1 ) )
      {
        *dst++ = '\'';
        skip = sizeof("apos;") - 1;

…e sequences that appear

Many items in the catalog contained the sequences '&ZZJHONS#40;' and '&ZZJHONS#41;' when printed in the file logs (such as with `verify brickowl`). These are now printed with the characters '(' and ')'.

Store names with an apostrophe were printed as '&ZZJHONS#39;' in the startup info messages. These now print using the correct puctuation.
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.

1 participant