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

Escape special characters in the XML generated in the delete() method #356

Closed

Conversation

ramayer
Copy link
Contributor

@ramayer ramayer commented Jan 22, 2021

Type pysolr .delete() method was not escaping special characters like <, >, and & in the XML it was generating.

In particular attempts to delete documents by IDs like this:

    self.solr.delete(id='cats<dogs')

would give error messages, and attempts to delete documents like this:

    self.solr.delete(q='id:*</query><query> id:999 AND id:9999')

could delete more than you would have expected. This pull request (with test cases) escape the IDs and Lucene Query Expressions in the XML generation step.

@ramayer
Copy link
Contributor Author

ramayer commented Jan 22, 2021

Note that this has the same functionality as [#358].

This version took the approach of using minimal changes building XML the same way.

The other version took the approach of changing Delete to use ElementTree to build the XML instead of python string manipulation.

I have no preference which approach is approved -- they both generate the same XML.

@ramayer
Copy link
Contributor Author

ramayer commented Jan 22, 2021

Based on comments in [#357], the different implementation of this fix under pull request [#358] is a better approach.

@ramayer ramayer closed this Jan 22, 2021
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