You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@nifi.apache.org by "bbende (via GitHub)" <gi...@apache.org> on 2024/02/14 16:46:43 UTC
[PR] NIFI-12788 Perform URL encoding on host returned from JettyServer Con… [nifi]
bbende opened a new pull request, #8404:
URL: https://github.com/apache/nifi/pull/8404
…nector
<!-- Licensed to the Apache Software Foundation (ASF) under one or more -->
<!-- contributor license agreements. See the NOTICE file distributed with -->
<!-- this work for additional information regarding copyright ownership. -->
<!-- The ASF licenses this file to You under the Apache License, Version 2.0 -->
<!-- (the "License"); you may not use this file except in compliance with -->
<!-- the License. You may obtain a copy of the License at -->
<!-- http://www.apache.org/licenses/LICENSE-2.0 -->
<!-- Unless required by applicable law or agreed to in writing, software -->
<!-- distributed under the License is distributed on an "AS IS" BASIS, -->
<!-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -->
<!-- See the License for the specific language governing permissions and -->
<!-- limitations under the License. -->
# Summary
[NIFI-12788](https://issues.apache.org/jira/browse/NIFI-12788)
# Tracking
Please complete the following tracking steps prior to pull request creation.
### Issue Tracking
- [X] [Apache NiFi Jira](https://issues.apache.org/jira/browse/NIFI) issue created
### Pull Request Tracking
- [X] Pull Request title starts with Apache NiFi Jira issue number, such as `NIFI-00000`
- [X] Pull Request commit message starts with Apache NiFi Jira issue number, as such `NIFI-00000`
### Pull Request Formatting
- [X] Pull Request based on current revision of the `main` branch
- [X] Pull Request refers to a feature branch with one commit containing changes
# Verification
Please indicate the verification steps performed prior to pull request creation.
### Build
- [X] Build completed using `mvn clean install -P contrib-check`
- [X] JDK 21
### Licensing
- [ ] New dependencies are compatible with the [Apache License 2.0](https://apache.org/licenses/LICENSE-2.0) according to the [License Policy](https://www.apache.org/legal/resolved.html)
- [ ] New dependencies are documented in applicable `LICENSE` and `NOTICE` files
### Documentation
- [ ] Documentation formatting appears as expected in rendered files
--
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: issues-unsubscribe@nifi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] NIFI-12788 Perform URL encoding on host returned from JettyServer Con… [nifi]
Posted by "dan-s1 (via GitHub)" <gi...@apache.org>.
dan-s1 commented on code in PR #8404:
URL: https://github.com/apache/nifi/pull/8404#discussion_r1490107134
##########
nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-jetty/src/main/java/org/apache/nifi/web/server/JettyServer.java:
##########
@@ -724,7 +726,7 @@ protected List<URI> getApplicationUrls() {
final String scheme = sslConnectionFactory == null ? HTTP_SCHEME : HTTPS_SCHEME;
final int port = serverConnector.getLocalPort();
final String connectorHost = serverConnector.getHost();
- final String host = StringUtils.defaultIfEmpty(connectorHost, HOST_UNSPECIFIED);
+ final String host = URLEncoder.encode(StringUtils.defaultIfEmpty(connectorHost, HOST_UNSPECIFIED), StandardCharsets.UTF_8);
return URI.create(String.format(APPLICATION_URL_FORMAT, scheme, host, port));
Review Comment:
Instead of using `URLEncoder` would using the seven argument constructor of `java.net.URI` be able to resolve to a URL?
I was able to take the parts of the URL you listed in the ticket and instantiate the following
`URI uri = new URI("https", null, "0:0:0:0:0:0:0:1%lo", 8443, "/nifi", null, null);`
which looks like
`https://[0:0:0:0:0:0:0:1%lo]:8443/nifi`
I am just unsure how `%lo` gets resolved.
If that works I would suggest replacing lines 729-730 with
```
final String host = StringUtils.defaultIfEmpty(connectorHost, HOST_UNSPECIFIED);
return new URI(scheme, null, host, port, "/nifi", null, null);
```
and get rid of `APPLICATION_URL_FORMAT` which is only used here.
--
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: issues-unsubscribe@nifi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] NIFI-12788 Perform URL encoding on host returned from JettyServer Con… [nifi]
Posted by "bbende (via GitHub)" <gi...@apache.org>.
bbende commented on code in PR #8404:
URL: https://github.com/apache/nifi/pull/8404#discussion_r1496198434
##########
nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-jetty/src/main/java/org/apache/nifi/web/server/JettyServer.java:
##########
@@ -724,7 +726,7 @@ protected List<URI> getApplicationUrls() {
final String scheme = sslConnectionFactory == null ? HTTP_SCHEME : HTTPS_SCHEME;
final int port = serverConnector.getLocalPort();
final String connectorHost = serverConnector.getHost();
- final String host = StringUtils.defaultIfEmpty(connectorHost, HOST_UNSPECIFIED);
+ final String host = URLEncoder.encode(StringUtils.defaultIfEmpty(connectorHost, HOST_UNSPECIFIED), StandardCharsets.UTF_8);
return URI.create(String.format(APPLICATION_URL_FORMAT, scheme, host, port));
Review Comment:
Thanks @dan-s1 , that seems like a simpler solution and does appear to work, the logs now show:
```
2024-02-20 12:06:40,195 INFO [main] org.apache.nifi.web.server.JettyServer Started Server on https://[fe80:0:0:0:c6d:9e76:6aff:9d0f%en0]:8443/nifi
2024-02-20 12:06:40,195 INFO [main] org.apache.nifi.web.server.JettyServer Started Server on https://192.168.1.169:8443/nifi
```
--
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: issues-unsubscribe@nifi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] NIFI-12788 Perform URL encoding on host returned from JettyServer Con… [nifi]
Posted by "dan-s1 (via GitHub)" <gi...@apache.org>.
dan-s1 commented on code in PR #8404:
URL: https://github.com/apache/nifi/pull/8404#discussion_r1490107134
##########
nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-jetty/src/main/java/org/apache/nifi/web/server/JettyServer.java:
##########
@@ -724,7 +726,7 @@ protected List<URI> getApplicationUrls() {
final String scheme = sslConnectionFactory == null ? HTTP_SCHEME : HTTPS_SCHEME;
final int port = serverConnector.getLocalPort();
final String connectorHost = serverConnector.getHost();
- final String host = StringUtils.defaultIfEmpty(connectorHost, HOST_UNSPECIFIED);
+ final String host = URLEncoder.encode(StringUtils.defaultIfEmpty(connectorHost, HOST_UNSPECIFIED), StandardCharsets.UTF_8);
return URI.create(String.format(APPLICATION_URL_FORMAT, scheme, host, port));
Review Comment:
Instead of using `URLEncoder` would using the seven argument constructor of `java.net.URI` be able to resolve to a URL?
I was able to take the parts of the URL you listed in the ticket and instantiate the following
`URI uri = new URI("https", null, "0:0:0:0:0:0:0:1%lo", 8443, "/nifi", null, null);`
which looks like
`https://[0:0:0:0:0:0:0:1%lo]:8443/nifi`
I am just unsure how `%lo` gets resolved.
--
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: issues-unsubscribe@nifi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] NIFI-12788 Perform URL encoding on host returned from JettyServer Con… [nifi]
Posted by "dan-s1 (via GitHub)" <gi...@apache.org>.
dan-s1 commented on code in PR #8404:
URL: https://github.com/apache/nifi/pull/8404#discussion_r1490107134
##########
nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-jetty/src/main/java/org/apache/nifi/web/server/JettyServer.java:
##########
@@ -724,7 +726,7 @@ protected List<URI> getApplicationUrls() {
final String scheme = sslConnectionFactory == null ? HTTP_SCHEME : HTTPS_SCHEME;
final int port = serverConnector.getLocalPort();
final String connectorHost = serverConnector.getHost();
- final String host = StringUtils.defaultIfEmpty(connectorHost, HOST_UNSPECIFIED);
+ final String host = URLEncoder.encode(StringUtils.defaultIfEmpty(connectorHost, HOST_UNSPECIFIED), StandardCharsets.UTF_8);
return URI.create(String.format(APPLICATION_URL_FORMAT, scheme, host, port));
Review Comment:
Instead of using `URLEncoder` would using the seven argument constructor of `java.net.URI` be able to resolve to a URL?
I was able to take the parts of the URL you listed in the ticket and instantiate the following
`URI uri = new URI("https", null, "0:0:0:0:0:0:0:1%lo", 8443, "/nifi", null, null);`
which looks like
`https://[0:0:0:0:0:0:0:1%lo]:8443/nifi`
I am just unsure how `%lo` gets resolved.
If that works I would suggest to replace lines 729-730 with
`return new URI(scheme, null, host, port, "/nifi", null, null);`
and get rid of `APPLICATION_URL_FORMAT` which is only used here.
--
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: issues-unsubscribe@nifi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] NIFI-12788 Perform URL encoding on host returned from JettyServer Con… [nifi]
Posted by "dan-s1 (via GitHub)" <gi...@apache.org>.
dan-s1 commented on code in PR #8404:
URL: https://github.com/apache/nifi/pull/8404#discussion_r1490107134
##########
nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-jetty/src/main/java/org/apache/nifi/web/server/JettyServer.java:
##########
@@ -724,7 +726,7 @@ protected List<URI> getApplicationUrls() {
final String scheme = sslConnectionFactory == null ? HTTP_SCHEME : HTTPS_SCHEME;
final int port = serverConnector.getLocalPort();
final String connectorHost = serverConnector.getHost();
- final String host = StringUtils.defaultIfEmpty(connectorHost, HOST_UNSPECIFIED);
+ final String host = URLEncoder.encode(StringUtils.defaultIfEmpty(connectorHost, HOST_UNSPECIFIED), StandardCharsets.UTF_8);
return URI.create(String.format(APPLICATION_URL_FORMAT, scheme, host, port));
Review Comment:
Instead of using `URLEncoder` would using the seven argument constructor of `java.net.URI` be able to resolve to a URL?
I was able to take the parts of the URL you listed in the ticket and instantiate the following
`URI uri = new URI("https", null, "0:0:0:0:0:0:0:1%lo", 8443, "/nifi", null, null);`
which looks like
`https://[0:0:0:0:0:0:0:1%lo]:8443/nifi`
I am just unsure how `%lo` gets resolved.
If that works I would suggest replacing lines 729-730 with
`return new URI(scheme, null, host, port, "/nifi", null, null);`
and get rid of `APPLICATION_URL_FORMAT` which is only used here.
--
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: issues-unsubscribe@nifi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] NIFI-12788 Perform URL encoding on host returned from JettyServer Con… [nifi]
Posted by "dan-s1 (via GitHub)" <gi...@apache.org>.
dan-s1 commented on code in PR #8404:
URL: https://github.com/apache/nifi/pull/8404#discussion_r1490107134
##########
nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-jetty/src/main/java/org/apache/nifi/web/server/JettyServer.java:
##########
@@ -724,7 +726,7 @@ protected List<URI> getApplicationUrls() {
final String scheme = sslConnectionFactory == null ? HTTP_SCHEME : HTTPS_SCHEME;
final int port = serverConnector.getLocalPort();
final String connectorHost = serverConnector.getHost();
- final String host = StringUtils.defaultIfEmpty(connectorHost, HOST_UNSPECIFIED);
+ final String host = URLEncoder.encode(StringUtils.defaultIfEmpty(connectorHost, HOST_UNSPECIFIED), StandardCharsets.UTF_8);
return URI.create(String.format(APPLICATION_URL_FORMAT, scheme, host, port));
Review Comment:
Instead of using `URLEncoder` would using the seven argument constructor of `java.net.URI` be able to resolve to a URL?
I was able to take the parts of the URL you listed in the ticket and instantiate the following in a unit test
`URI uri = new URI("https", null, "0:0:0:0:0:0:0:1%lo", 8443, "/nifi", null, null);`
I am just unsure how `%lo` gets resolved.
--
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: issues-unsubscribe@nifi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] NIFI-12788 Perform URL encoding on host returned from JettyServer Con… [nifi]
Posted by "exceptionfactory (via GitHub)" <gi...@apache.org>.
exceptionfactory closed pull request #8404: NIFI-12788 Perform URL encoding on host returned from JettyServer Con…
URL: https://github.com/apache/nifi/pull/8404
--
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: issues-unsubscribe@nifi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] NIFI-12788 Perform URL encoding on host returned from JettyServer Con… [nifi]
Posted by "dan-s1 (via GitHub)" <gi...@apache.org>.
dan-s1 commented on code in PR #8404:
URL: https://github.com/apache/nifi/pull/8404#discussion_r1490107134
##########
nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-jetty/src/main/java/org/apache/nifi/web/server/JettyServer.java:
##########
@@ -724,7 +726,7 @@ protected List<URI> getApplicationUrls() {
final String scheme = sslConnectionFactory == null ? HTTP_SCHEME : HTTPS_SCHEME;
final int port = serverConnector.getLocalPort();
final String connectorHost = serverConnector.getHost();
- final String host = StringUtils.defaultIfEmpty(connectorHost, HOST_UNSPECIFIED);
+ final String host = URLEncoder.encode(StringUtils.defaultIfEmpty(connectorHost, HOST_UNSPECIFIED), StandardCharsets.UTF_8);
return URI.create(String.format(APPLICATION_URL_FORMAT, scheme, host, port));
Review Comment:
Instead of using `URLEncoder` would using the seven argument constructor of `java.net.URI` be able to resolve to a URL?
I was able to take the parts of the URL you listed in the ticket and instantiate the following
`URI uri = new URI("https", null, "0:0:0:0:0:0:0:1%lo", 8443, "/nifi", null, null);`
which looks like
`https://[0:0:0:0:0:0:0:1%lo]:8443/nifi`
I am just unsure how `%lo` gets resolved.
If that works I would suggest to replace lines 729-730 with
`return new URI(scheme, null, host, port, "/nifi", null, null);`
and get rid of `APPLICATION_URL_FORMAT` which is only used here.
--
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: issues-unsubscribe@nifi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] NIFI-12788 Perform URL encoding on host returned from JettyServer Con… [nifi]
Posted by "dan-s1 (via GitHub)" <gi...@apache.org>.
dan-s1 commented on code in PR #8404:
URL: https://github.com/apache/nifi/pull/8404#discussion_r1490107134
##########
nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-jetty/src/main/java/org/apache/nifi/web/server/JettyServer.java:
##########
@@ -724,7 +726,7 @@ protected List<URI> getApplicationUrls() {
final String scheme = sslConnectionFactory == null ? HTTP_SCHEME : HTTPS_SCHEME;
final int port = serverConnector.getLocalPort();
final String connectorHost = serverConnector.getHost();
- final String host = StringUtils.defaultIfEmpty(connectorHost, HOST_UNSPECIFIED);
+ final String host = URLEncoder.encode(StringUtils.defaultIfEmpty(connectorHost, HOST_UNSPECIFIED), StandardCharsets.UTF_8);
return URI.create(String.format(APPLICATION_URL_FORMAT, scheme, host, port));
Review Comment:
Instead of using `URLEncoder` would using the seven argument constructor of `java.net.URI` be able to resolve to a URL?
I was able to take the parts of the URL you listed in the ticket and instantiate the following in a unit test
`URI uri = new URI("https", null, "0:0:0:0:0:0:0:1%lo", 8443, "/nifi", null, null);`
which looks like
`https://[0:0:0:0:0:0:0:1%lo]:8443/nifi`
I am just unsure how `%lo` gets resolved.
--
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: issues-unsubscribe@nifi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] NIFI-12788 Perform URL encoding on host returned from JettyServer Con… [nifi]
Posted by "bbende (via GitHub)" <gi...@apache.org>.
bbende commented on code in PR #8404:
URL: https://github.com/apache/nifi/pull/8404#discussion_r1496198434
##########
nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-jetty/src/main/java/org/apache/nifi/web/server/JettyServer.java:
##########
@@ -724,7 +726,7 @@ protected List<URI> getApplicationUrls() {
final String scheme = sslConnectionFactory == null ? HTTP_SCHEME : HTTPS_SCHEME;
final int port = serverConnector.getLocalPort();
final String connectorHost = serverConnector.getHost();
- final String host = StringUtils.defaultIfEmpty(connectorHost, HOST_UNSPECIFIED);
+ final String host = URLEncoder.encode(StringUtils.defaultIfEmpty(connectorHost, HOST_UNSPECIFIED), StandardCharsets.UTF_8);
return URI.create(String.format(APPLICATION_URL_FORMAT, scheme, host, port));
Review Comment:
Thanks @dan-s1 , that seems like a simpler solution and does appear to work
--
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: issues-unsubscribe@nifi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org