Skip to content
This repository has been archived by the owner on Nov 1, 2023. It is now read-only.

Commit

Permalink
Fix #22963: URL encoding errors when http2 is enabled
Browse files Browse the repository at this point in the history
Signed-off-by: Taylor Smock <[email protected]>
  • Loading branch information
tsmock committed May 24, 2023
1 parent 1138a62 commit e52c8b8
Showing 1 changed file with 24 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,25 @@ public interface IMapillaryUrls {
*/
String getAccessId();

/**
* Get the access id in a URL safe manner (the http2 plugin doesn't like {@code "|"} characters)
*
* @return The access id
*/
default String getUrlEncodedAccessId() {
final String originalAccessId = getAccessId();
if (originalAccessId == null) {
return null;
}
try {
// Once we move to Java 10+, we can drop the name() and the catch
return URLEncoder.encode(originalAccessId, StandardCharsets.UTF_8.name());
} catch (UnsupportedEncodingException unsupportedEncodingException) {
// We've hardcoded the UTF-8 charset, so this should never happen unless Java drops UTF_8.
throw new JosmRuntimeException(unsupportedEncodingException);
}
}

/**
* Get the client id
*
Expand Down Expand Up @@ -91,7 +110,7 @@ public interface IMapillaryUrls {
*/
default String getTrafficSigns() {
return MapillaryConfig.getUrls().getBaseTileUrl() + "mly_map_feature_traffic_sign/2/{z}/{x}/{y}?access_token="
+ getAccessId();
+ getUrlEncodedAccessId();
}

/**
Expand All @@ -101,7 +120,7 @@ default String getTrafficSigns() {
*/
default String getObjectDetections() {
return MapillaryConfig.getUrls().getBaseTileUrl() + "mly_map_feature_point/2/{z}/{x}/{y}?access_token="
+ getAccessId();
+ getUrlEncodedAccessId();
}

/**
Expand All @@ -124,9 +143,10 @@ default String getDetectionInformation(long image) {
default String getImages() {
if (Boolean.TRUE.equals(MapillaryProperties.USE_COMPUTED_LOCATIONS.get())) {
return MapillaryConfig.getUrls().getBaseTileUrl() + "mly1_computed_public/2/{z}/{x}/{y}?access_token="
+ getAccessId();
+ getUrlEncodedAccessId();
}
return MapillaryConfig.getUrls().getBaseTileUrl() + "mly1_public/2/{z}/{x}/{y}?access_token=" + getAccessId();
return MapillaryConfig.getUrls().getBaseTileUrl() + "mly1_public/2/{z}/{x}/{y}?access_token="
+ getUrlEncodedAccessId();
}

/**
Expand Down

0 comments on commit e52c8b8

Please sign in to comment.