[jira] [Commented] (SOLR-17255) ClientUtils.encodeLocalParamVal doesn't work with param refs, breaks SolrParams.toLocalParamsString

2024-06-18 Thread David Smiley (Jira)


[ 
https://issues.apache.org/jira/browse/SOLR-17255?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17855919#comment-17855919
 ] 

David Smiley commented on SOLR-17255:
-

+1 thanks

> ClientUtils.encodeLocalParamVal doesn't work with param refs, breaks 
> SolrParams.toLocalParamsString
> ---
>
> Key: SOLR-17255
> URL: https://issues.apache.org/jira/browse/SOLR-17255
> Project: Solr
>  Issue Type: Bug
>  Components: SolrJ
>Reporter: Chris M. Hostetter
>Assignee: Chris M. Hostetter
>Priority: Major
> Attachments: SOLR-17255.patch
>
>
> If you try to use {{SolrParams.toLocalParamsString}} where some of your param 
> values are {{$other_param}} style param references, those refs will wind up 
> wrapped in single quotes, preventing the param de-referencing from working.
> Example...
> {code:java}
> final ModifiableSolrParams params = new ModifiableSolrParams();
> params.set("type", "edismax");
> params.set("v","$other_param");
> System.out.println(params.toLocalParamString())
> // Output: {! type=edismax v='$other_param'}
> {code}
> Ironically: {{ClientUtils.encodeLocalParamVal}} actually has a check to see 
> if the string starts with {{"$"}} which causes it to bypass a loop that 
> checks to see if the string needs to be quoted – but bypassing that loop 
> doesn't leave the method variables ({{{}i{}}} and {{{}len{}}}) in a state 
> that allow the subsequent short-circut check (which returns the original 
> value) to kick in – so the value is always falls through to the {{// We need 
> to enclose in quotes... but now we need to escape}} logic
> (It looks like this bug has always existed in every version of these methods)



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

-
To unsubscribe, e-mail: issues-unsubscr...@solr.apache.org
For additional commands, e-mail: issues-h...@solr.apache.org



[jira] [Commented] (SOLR-17255) ClientUtils.encodeLocalParamVal doesn't work with param refs, breaks SolrParams.toLocalParamsString

2024-04-24 Thread Chris M. Hostetter (Jira)


[ 
https://issues.apache.org/jira/browse/SOLR-17255?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17840584#comment-17840584
 ] 

Chris M. Hostetter commented on SOLR-17255:
---

Thinking about it more: {{SolrParams.toLocalParamsString}} also probably has a 
bug if/when the value is the empty string? ... 

Pretty sure a use case like this will break because it will produce something 
like  {{... bq= v=foo ...}} which will cause solr to try to use {{v=foo}} as 
the value for the {{bq}} local param.  Empty strings in local params need to be 
quoted.

{code}
final ModifiableSolrParams params = new ModifiableSolrParams();
params.set("type", "edismax");
params.set("bq","");
params.set("v","foo");
System.out.println(params.toLocalParamString())
{code}


> ClientUtils.encodeLocalParamVal doesn't work with param refs, breaks 
> SolrParams.toLocalParamsString
> ---
>
> Key: SOLR-17255
> URL: https://issues.apache.org/jira/browse/SOLR-17255
> Project: Solr
>  Issue Type: Bug
>  Security Level: Public(Default Security Level. Issues are Public) 
>  Components: SolrJ
>Reporter: Chris M. Hostetter
>Priority: Major
>
> If you try to use {{SolrParams.toLocalParamsString}} where some of your param 
> values are {{$other_param}} style param references, those refs will wind up 
> wrapped in single quotes, preventing the param de-referencing from working.
> Example...
> {code:java}
> final ModifiableSolrParams params = new ModifiableSolrParams();
> params.set("type", "edismax");
> params.set("v","$other_param");
> System.out.println(params.toLocalParamString())
> // Output: {! type=edismax v='$other_param'}
> {code}
> Ironically: {{ClientUtils.encodeLocalParamVal}} actually has a check to see 
> if the string starts with {{"$"}} which causes it to bypass a loop that 
> checks to see if the string needs to be quoted – but bypassing that loop 
> doesn't leave the method variables ({{{}i{}}} and {{{}len{}}}) in a state 
> that allow the subsequent short-circut check (which returns the original 
> value) to kick in – so the value is always falls through to the {{// We need 
> to enclose in quotes... but now we need to escape}} logic
> (It looks like this bug has always existed in every version of these methods)



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

-
To unsubscribe, e-mail: issues-unsubscr...@solr.apache.org
For additional commands, e-mail: issues-h...@solr.apache.org



[jira] [Commented] (SOLR-17255) ClientUtils.encodeLocalParamVal doesn't work with param refs, breaks SolrParams.toLocalParamsString

2024-04-24 Thread Chris M. Hostetter (Jira)


[ 
https://issues.apache.org/jira/browse/SOLR-17255?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17840583#comment-17840583
 ] 

Chris M. Hostetter commented on SOLR-17255:
---

I think you added  {{SolrParams.toLocalParamsString}} but the logic for 
handling in {{ClientUtils.encodeLocalParamVal}} dates back much older – it 
looks like it was intentionally added by SOLR-2110 ?  I haven't really dug 
into the history but it looks like that jira (and the tests it add) are trying 
to ensure that values starting with {{"$"}} are *intentionally* quoted ... 
evidently because of how some facet refinement logic (that calls 
{{encodeLocalParamVal}} directly) duplicates {{"key"}} local params  and it 
must have been trying to derefrence the values when it shouldn't have been?

I suspect the "correct" fix (w/o breaking faceting) is that 
{{SolrParams.toLocalParamsString}} should special case check for param refs, 
and not delegate to {{ClientUtils.encodeLocalParamVal}} in that case?  (and of 
course: a lot more tests and javadocs about what callers can/should expect)

> ClientUtils.encodeLocalParamVal doesn't work with param refs, breaks 
> SolrParams.toLocalParamsString
> ---
>
> Key: SOLR-17255
> URL: https://issues.apache.org/jira/browse/SOLR-17255
> Project: Solr
>  Issue Type: Bug
>  Security Level: Public(Default Security Level. Issues are Public) 
>  Components: SolrJ
>Reporter: Chris M. Hostetter
>Priority: Major
>
> If you try to use {{SolrParams.toLocalParamsString}} where some of your param 
> values are {{$other_param}} style param references, those refs will wind up 
> wrapped in single quotes, preventing the param de-referencing from working.
> Example...
> {code:java}
> final ModifiableSolrParams params = new ModifiableSolrParams();
> params.set("type", "edismax");
> params.set("v","$other_param");
> System.out.println(params.toLocalParamString())
> // Output: {! type=edismax v='$other_param'}
> {code}
> Ironically: {{ClientUtils.encodeLocalParamVal}} actually has a check to see 
> if the string starts with {{"$"}} which causes it to bypass a loop that 
> checks to see if the string needs to be quoted – but bypassing that loop 
> doesn't leave the method variables ({{{}i{}}} and {{{}len{}}}) in a state 
> that allow the subsequent short-circut check (which returns the original 
> value) to kick in – so the value is always falls through to the {{// We need 
> to enclose in quotes... but now we need to escape}} logic
> (It looks like this bug has always existed in every version of these methods)



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

-
To unsubscribe, e-mail: issues-unsubscr...@solr.apache.org
For additional commands, e-mail: issues-h...@solr.apache.org



[jira] [Commented] (SOLR-17255) ClientUtils.encodeLocalParamVal doesn't work with param refs, breaks SolrParams.toLocalParamsString

2024-04-24 Thread David Smiley (Jira)


[ 
https://issues.apache.org/jira/browse/SOLR-17255?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17840578#comment-17840578
 ] 

David Smiley commented on SOLR-17255:
-

Ouch; good catch!  I recall writing that a long time ago.

> ClientUtils.encodeLocalParamVal doesn't work with param refs, breaks 
> SolrParams.toLocalParamsString
> ---
>
> Key: SOLR-17255
> URL: https://issues.apache.org/jira/browse/SOLR-17255
> Project: Solr
>  Issue Type: Bug
>  Security Level: Public(Default Security Level. Issues are Public) 
>  Components: SolrJ
>Reporter: Chris M. Hostetter
>Priority: Major
>
> If you try to use {{SolrParams.toLocalParamsString}} where some of your param 
> values are {{$other_param}} style param references, those refs will wind up 
> wrapped in single quotes, preventing the param de-referencing from working.
> Example...
> {code:java}
> final ModifiableSolrParams params = new ModifiableSolrParams();
> params.set("type", "edismax");
> params.set("v","$other_param");
> System.out.println(params.toLocalParamString())
> // Output: {! type=edismax v='$other_param'}
> {code}
> Ironically: {{ClientUtils.encodeLocalParamVal}} actually has a check to see 
> if the string starts with {{"$"}} which causes it to bypass a loop that 
> checks to see if the string needs to be quoted – but bypassing that loop 
> doesn't leave the method variables ({{{}i{}}} and {{{}len{}}}) in a state 
> that allow the subsequent short-circut check (which returns the original 
> value) to kick in – so the value is always falls through to the {{// We need 
> to enclose in quotes... but now we need to escape}} logic
> (It looks like this bug has always existed in every version of these methods)



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

-
To unsubscribe, e-mail: issues-unsubscr...@solr.apache.org
For additional commands, e-mail: issues-h...@solr.apache.org