Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SOLR-16810: Under certain situations Solr produces managed schema XML with duplicate fields #1654

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

thiru-mg
Copy link

@thiru-mg thiru-mg commented May 21, 2023

https://issues.apache.org/jira/browse/SOLR-16810

Description

While persisting the ManagedIndexSchema as XML, non-printable characters in field names get escaped as #nn;, where nn is the decimal representation of the non-printable character. For example, if the field name has the byte 0x14, it gets escaped as #20;. This in indistinguishable from the literal #20; in the field name. If we have two fields - one with the non-printable character and the other with the literal string, two fields get generated with the same name. Loading the resulting XML, naturally, causes an exception. To fix this, any occurrence of literal # in the field name should be escaped, with say ##.
A second problem is that while escaping happens when generating XML, the corresponding unescaping does not happen on loading it.

Solution

Both the suggested fixes are here. There are tests to expose the bugs and the fixes that pass the tests.

Tests

Added two sets of tests - one for IndexSchema.java and the other for XML.java

Checklist

Please review the following and check all that apply:

  • I have reviewed the guidelines for How to Contribute and my code conforms to the standards described there to the best of my ability.
  • I have created a Jira issue and added the issue ID to my pull request title.
  • I have given Solr maintainers access to contribute to my PR branch. (optional but recommended)
  • I have developed this patch against the main branch.
  • I have run ./gradlew check.
  • I have added tests for my changes.
  • I have added documentation for the Reference Guide

sb.append(g3);
} else {
sb.append(m.group(2));
sb.append(escapes[m.group(5).charAt(0)]);
Copy link

Choose a reason for hiding this comment

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

15% of developers fix this issue

NULL_DEREFERENCE: object returned by m.group(5) could be null and is dereferenced at line 247.


ℹ️ Expand to see all @sonatype-lift commands

You can reply with the following commands. For example, reply with @sonatype-lift ignoreall to leave out all findings.

Command Usage
@sonatype-lift ignore Leave out the above finding from this PR
@sonatype-lift ignoreall Leave out all the existing findings from this PR
@sonatype-lift exclude <file|issue|path|tool> Exclude specified file|issue|path|tool from Lift findings by updating your config.toml file

Note: When talking to LiftBot, you need to refresh the page to see its response.
Click here to add LiftBot to another repo.

@noblepaul noblepaul changed the title SOLR-16810: Under certain situations Solr produces managed schema XML that cannot be loaded SOLR-16810: Under certain situations Solr produces managed schema XML with duplicate fields May 22, 2023
Copy link

This PR had no visible activity in the past 60 days, labeling it as stale. Any new activity will remove the stale label. To attract more reviewers, please tag someone or notify the dev@solr.apache.org mailing list. Thank you for your contribution!

@github-actions github-actions bot added the stale PR not updated in 60 days label Feb 15, 2024
@epugh
Copy link
Contributor

epugh commented Feb 15, 2024

Thank you StaleBot..... I just checked the JIRA and I was last to chime in, so I'll take this and try and get it over the finish line.

@github-actions github-actions bot removed the stale PR not updated in 60 days label Mar 1, 2024
Copy link

github-actions bot commented May 1, 2024

This PR had no visible activity in the past 60 days, labeling it as stale. Any new activity will remove the stale label. To attract more reviewers, please tag someone or notify the dev@solr.apache.org mailing list. Thank you for your contribution!

@github-actions github-actions bot added the stale PR not updated in 60 days label May 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
client:solrj stale PR not updated in 60 days
Projects
None yet
2 participants