You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@calcite.apache.org by "alhudz (via GitHub)" <gi...@apache.org> on 2026/06/10 05:07:22 UTC
[PR] quote parse_url key before building the query regex [calcite]
alhudz opened a new pull request, #5008:
URL: https://github.com/apache/calcite/pull/5008
## Jira Link
A Jira can be filed for this if preferred; raising the patch first since the change is a small, self-contained fix.
## Changes Proposed
`Repro:` `parse_url('http://h/p?k1=v1&k2=v2', 'QUERY', 'k.')` and `parse_url('http://h/p?k1=v1', 'QUERY', '(')`.
`Expected:` the first returns `NULL` (no parameter is literally named `k.`); the second returns `NULL` (no parameter named `(`).
`Actual:` `ParseUrlFunction.keyToPattern` builds the lookup with `Pattern.compile("(&|^)" + keyToExtract + "=([^&]*)")`, so the key is spliced into the regex unescaped. The key is the third `PARSE_URL` argument and crosses the trust boundary. Regex metacharacters in the key are interpreted, so `k.` matches `k1` and wrongly returns `v1`, and a key that is not a valid regex such as `(` throws `PatternSyntaxException` out of the function instead of yielding a result.
`Fix:` wrap the key in `Pattern.quote` so it is matched literally, which is the documented key semantics. `Pattern.quote` is already the idiom used elsewhere in `SqlFunctions` (the `split` helper).
`Test:` `SqlOperatorTest.testParseUrl` gains cases for a metacharacter key and a non-regex key; both fail on the unpatched tree and pass after.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [CALCITE-7600] Quote PARSE_URL key before building the query regex [calcite]
Posted by "alhudz (via GitHub)" <gi...@apache.org>.
alhudz commented on PR #5008:
URL: https://github.com/apache/calcite/pull/5008#issuecomment-4677810505
Thanks for the feedback. I've created JIRA issue CALCITE-7600 and updated the PR title and commit message to reference it.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [CALCITE-7600] Quote PARSE_URL key before building the query regex [calcite]
Posted by "alhudz (via GitHub)" <gi...@apache.org>.
alhudz commented on PR #5008:
URL: https://github.com/apache/calcite/pull/5008#issuecomment-4683590770
Thanks for the review and for getting this merged. I appreciate the feedback on the process as well. Glad I could contribute
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] quote parse_url key before building the query regex [calcite]
Posted by "rubenada (via GitHub)" <gi...@apache.org>.
rubenada commented on PR #5008:
URL: https://github.com/apache/calcite/pull/5008#issuecomment-4668507604
Thanks for the contribution @alhudz !
Please take a look at our [contribution guidelines](https://calcite.apache.org/develop/#contributing) to make sure your proposal is aligned with them (Jira ticket, PR title / commit message referring to it, etc)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [CALCITE-7600] Quote PARSE_URL key before building the query regex [calcite]
Posted by "mihaibudiu (via GitHub)" <gi...@apache.org>.
mihaibudiu merged PR #5008:
URL: https://github.com/apache/calcite/pull/5008
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] quote parse_url key before building the query regex [calcite]
Posted by "mihaibudiu (via GitHub)" <gi...@apache.org>.
mihaibudiu commented on PR #5008:
URL: https://github.com/apache/calcite/pull/5008#issuecomment-4671876891
The fix looks good, but I think @rubenada is right, filing a JIRA issue for this is useful
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [CALCITE-7600] Quote PARSE_URL key before building the query regex [calcite]
Posted by "sonarqubecloud[bot] (via GitHub)" <gi...@apache.org>.
sonarqubecloud[bot] commented on PR #5008:
URL: https://github.com/apache/calcite/pull/5008#issuecomment-4677932280
## [](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=5008) **Quality Gate passed**
Issues
 [0 New issues](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=5008&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)
 [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=5008&issueStatuses=ACCEPTED)
Measures
 [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_calcite&pullRequest=5008&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)
 [100.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=5008&metric=new_coverage&view=list)
 [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=5008&metric=new_duplicated_lines_density&view=list)
<!-- sqra-placement-anchor -->
[See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=5008)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org