-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Fix single double quote breaking solr query #10405
Fix single double quote breaking solr query #10405
Conversation
The following tests are failing:
|
Probably will move my test to |
b4c2ca5
to
8ea478d
Compare
…o_solr_params [ln 484] and edit tests
da168bc
to
cee2429
Compare
be4c806
to
477bae6
Compare
for more information, see https://pre-commit.ci
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I spent some time researching/debugging this one, and I think I found a better solution.
Escaping the "
to embed it in the larger edismax query is potentially a bit of a security risk, since if we don't escape it correctly, a user could effectively run any complicated query on our solr!
We can avoid escaping it to embed in the edismax query entirely, if we take advantage of a solr feature that lets us put edismax parameters in separate url params. E.g.
?q={!edismax v=$someParam}
&someParam=users raw "query
Testing this out on testing now...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hit one issue about editions.q having a different scope for the template query parameters (?!?!) but appears to be working now!
Great work on finding the root cause of this @tomrod10 !
Closes #10390
Searching with an unmatched double quote
"
, causes the Solr query to be invalid/break.On line 484 in
~/openlibrary/plugins/worksearch/schemes/works.py
it looks like it escapes already escaped"
. Therefore turning the string:'Compilation Group for the \\"History of Modern China'
into'Compilation Group for the \\\\"History of Modern China'
.I edited the code on line 484 to only escape
"
if\\"
is not in theed_q
string. Otherwise, either all"
will be escaped ifed_q
is not falsy, else the kwargv
will be set to*:*
.Technical
Testing
Added tests:
~/openlibrary/plugins/worksearch/schemes/tests/test_works.py
Manual testing:
"
Screenshot
Stakeholders
@cdrini