[ 
https://issues.apache.org/jira/browse/NIFI-12513?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17798343#comment-17798343
 ] 

Daniel Stieglitz edited comment on NIFI-12513 at 12/18/23 8:37 PM:
-------------------------------------------------------------------

[~pvillard] It would seem this issue is not specific to InvokeHttp but with the 
StandardValidators.URL_VALIDATOR as the URL you listed fails when called with  
{code:java}
URI.create(evaluatedInput).toURL();{code}
The same logic is called in InvokeHTTP but any PropertyDescriptor which uses 
the StandardValidators.URL_VALIDATOR will fail to validate.

I found this [Stackoverflow 
post|https://stackoverflow.com/questions/75966165/how-to-replace-the-deprecated-url-constructors-in-java-20]
 helpful understanding that the issue is probably an encoding issue. I think 
using this [URI constructor 
|https://docs.oracle.com/javase/8/docs/api/java/net/URI.html#URI-java.lang.String-java.lang.String-java.lang.String-int-java.lang.String-java.lang.String-java.lang.String-]would
 help as it would identify which parts needs to be encoded (escaped). The issue 
though is we would need to parse the user entered URL to identify its 
components. I found the following [API|https://github.com/smola/galimatias] 
(though its a little old) which can handle parsing the components and convert 
it to a java.netURL / java.net.URI. Could we wrap the use of this API in a 
utility method and then use it in StandardValidators.URL_VALIDATOR and all the 
classes which require parsing a URL to a java.netURL / java.net.URI object?


was (Author: JIRAUSER294662):
[~pvillard] It would seem this issue is not specific to InvokeHttp but with the 
StandardValidators.URL_VALIDATOR as the URL you listed fails when called with  
{code:java}
URI.create(evaluatedInput).toURL();{code}
The same logic is called in InvokeHTTP but any PropertyDescriptor which uses 
the StandardValidators.URL_VALIDATOR will fail to validate.

I found this [Stackoverflow 
post|https://stackoverflow.com/questions/75966165/how-to-replace-the-deprecated-url-constructors-in-java-20]
 helpful understanding that the issue is probably an encoding issue. I think 
using this [URI constructor 
|https://docs.oracle.com/javase/8/docs/api/java/net/URI.html#URI-java.lang.String-java.lang.String-java.lang.String-int-java.lang.String-java.lang.String-java.lang.String-]]would
 help as it would identify which parts needs to be encoded (escaped). The issue 
though is we would need to parse the user entered URL to identify its 
components. I found the following [API|https://github.com/smola/galimatias] 
(though its a little old) which can handle parsing the components and convert 
it to a java.netURL / java.net.URI. Could we wrap the use of this API in a 
utility method and then use it in StandardValidators.URL_VALIDATOR and all the 
classes which require parsing a URL to a java.netURL / java.net.URI object?

> Regression in InvokeHTTP - Not a valid URL
> ------------------------------------------
>
>                 Key: NIFI-12513
>                 URL: https://issues.apache.org/jira/browse/NIFI-12513
>             Project: Apache NiFi
>          Issue Type: Bug
>          Components: Extensions
>    Affects Versions: 2.0.0-M1, 1.24.0
>            Reporter: Pierre Villard
>            Assignee: Daniel Stieglitz
>            Priority: Major
>
> On NiFi 1.24 and NiFi 2.0-M1, the below URL
> {code:java}
> https://en.wikipedia.org/w/api.php?action=query&list=recentchanges&format=json&rcprop=user|comment|parsedcomment|timestamp|title|sizes|tags{code}
> Is no longer considered as valid but it was a valid one before.



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

Reply via email to