mirror of
https://github.com/hapifhir/org.hl7.fhir.core.git
synced 2025-03-09 14:31:17 +00:00
Merge pull request #1880 from hapifhir/do-20250114-fix-param-encode
Use URLEncoder.encode, deprecate worse named method
This commit is contained in:
commit
8c039244a5
@ -342,7 +342,7 @@ public class FHIRToolingClient extends FHIRBaseToolingClient {
|
||||
if (!complex)
|
||||
for (ParametersParameterComponent p : params.getParameter())
|
||||
if (p.getValue() instanceof PrimitiveType)
|
||||
ps += p.getName() + "=" + Utilities.encodeUri(((PrimitiveType) p.getValue()).asStringValue()) + "&";
|
||||
ps += p.getName() + "=" + Utilities.encodeUriParam(((PrimitiveType) p.getValue()).asStringValue()) + "&";
|
||||
ResourceRequest<T> result;
|
||||
if (complex)
|
||||
result = utils.issuePostRequest(resourceAddress.resolveOperationURLFromClass(resourceClass, name, ps),
|
||||
|
@ -426,7 +426,7 @@ public class ResourceAddress {
|
||||
} else {
|
||||
query = "";
|
||||
}
|
||||
query += httpParameterName + "=" + Utilities.encodeUri(parameters.get(httpParameterName));
|
||||
query += httpParameterName + "=" + Utilities.encodeUriParam(parameters.get(httpParameterName));
|
||||
}
|
||||
|
||||
return new URI(basePath.getScheme(), basePath.getUserInfo(), basePath.getHost(), basePath.getPort(),
|
||||
|
@ -522,7 +522,7 @@ public class FHIRToolingClient extends FHIRBaseToolingClient {
|
||||
if (!complex)
|
||||
for (ParametersParameterComponent p : params.getParameter())
|
||||
if (p.getValue() instanceof PrimitiveType)
|
||||
ps += p.getName() + "=" + Utilities.encodeUri(((PrimitiveType) p.getValue()).asStringValue()) + "&";
|
||||
ps += p.getName() + "=" + Utilities.encodeUriParam(((PrimitiveType) p.getValue()).asStringValue()) + "&";
|
||||
ResourceRequest<T> result;
|
||||
if (complex)
|
||||
result = utils.issuePostRequest(resourceAddress.resolveOperationURLFromClass(resourceClass, name, ps),
|
||||
|
@ -427,7 +427,7 @@ public class ResourceAddress {
|
||||
} else {
|
||||
query = "";
|
||||
}
|
||||
query += httpParameterName + "=" + Utilities.encodeUri(parameters.get(httpParameterName));
|
||||
query += httpParameterName + "=" + Utilities.encodeUriParam(parameters.get(httpParameterName));
|
||||
}
|
||||
|
||||
return new URI(basePath.getScheme(), basePath.getUserInfo(), basePath.getHost(), basePath.getPort(),
|
||||
|
@ -312,7 +312,7 @@ public class FHIRToolingClient extends FHIRBaseToolingClient {
|
||||
if (!complex)
|
||||
for (ParametersParameterComponent p : params.getParameter())
|
||||
if (p.getValue() instanceof PrimitiveType)
|
||||
ps += p.getName() + "=" + Utilities.encodeUri(((PrimitiveType) p.getValue()).asStringValue()) + "&";
|
||||
ps += p.getName() + "=" + Utilities.encodeUriParam(((PrimitiveType) p.getValue()).asStringValue()) + "&";
|
||||
ResourceRequest<T> result;
|
||||
URI url = resourceAddress.resolveOperationURLFromClass(resourceClass, name, ps);
|
||||
if (complex) {
|
||||
|
@ -418,7 +418,7 @@ public class ResourceAddress {
|
||||
} else {
|
||||
query = "";
|
||||
}
|
||||
query += httpParameterName + "=" + Utilities.encodeUri(parameters.get(httpParameterName));
|
||||
query += httpParameterName + "=" + Utilities.encodeUriParam(parameters.get(httpParameterName));
|
||||
}
|
||||
|
||||
return new URI(basePath.getScheme(), basePath.getUserInfo(), basePath.getHost(),basePath.getPort(), basePath.getPath(), query, basePath.getFragment());
|
||||
|
@ -288,7 +288,7 @@ public class FHIRToolingClient extends FHIRBaseToolingClient {
|
||||
if (!complex)
|
||||
for (ParametersParameterComponent p : params.getParameter())
|
||||
if (p.getValue() instanceof PrimitiveType)
|
||||
ps += p.getName() + "=" + Utilities.encodeUri(((PrimitiveType) p.getValue()).asStringValue()) + "&";
|
||||
ps += p.getName() + "=" + Utilities.encodeUriParam(((PrimitiveType) p.getValue()).asStringValue()) + "&";
|
||||
ResourceRequest<T> result;
|
||||
URI url = resourceAddress.resolveOperationURLFromClass(resourceClass, name, ps);
|
||||
if (complex) {
|
||||
|
@ -433,7 +433,7 @@ public class ResourceAddress {
|
||||
} else {
|
||||
query = "";
|
||||
}
|
||||
query += httpParameterName + "=" + Utilities.encodeUri(parameters.get(httpParameterName));
|
||||
query += httpParameterName + "=" + Utilities.encodeUriParam(parameters.get(httpParameterName));
|
||||
}
|
||||
|
||||
return new URI(basePath.getScheme(), basePath.getUserInfo(), basePath.getHost(), basePath.getPort(),
|
||||
|
@ -301,7 +301,7 @@ public class FHIRToolingClient extends FHIRBaseToolingClient{
|
||||
if (!complex)
|
||||
for (ParametersParameterComponent p : params.getParameter())
|
||||
if (p.getValue() instanceof PrimitiveType)
|
||||
ps += p.getName() + "=" + Utilities.encodeUri(((PrimitiveType) p.getValue()).asStringValue()) + "&";
|
||||
ps += p.getName() + "=" + Utilities.encodeUriParam(((PrimitiveType) p.getValue()).asStringValue()) + "&";
|
||||
ResourceRequest<T> result;
|
||||
URI url = resourceAddress.resolveOperationURLFromClass(resourceClass, name, ps);
|
||||
if (complex) {
|
||||
|
@ -424,7 +424,7 @@ public class ResourceAddress {
|
||||
} else {
|
||||
query = "";
|
||||
}
|
||||
query += httpParameterName + "=" + Utilities.encodeUri(parameters.get(httpParameterName));
|
||||
query += httpParameterName + "=" + Utilities.encodeUriParam(parameters.get(httpParameterName));
|
||||
}
|
||||
|
||||
return new URI(basePath.getScheme(), basePath.getUserInfo(), basePath.getHost(), basePath.getPort(),
|
||||
|
@ -345,7 +345,7 @@ public class FHIRToolingClient extends FHIRBaseToolingClient {
|
||||
if (!complex)
|
||||
for (ParametersParameterComponent p : params.getParameter())
|
||||
if (p.getValue() instanceof PrimitiveType)
|
||||
ps += p.getName() + "=" + Utilities.encodeUri(((PrimitiveType) p.getValue()).asStringValue()) + "&";
|
||||
ps += p.getName() + "=" + Utilities.encodeUriParam(((PrimitiveType) p.getValue()).asStringValue()) + "&";
|
||||
ResourceRequest<T> result;
|
||||
URI url = resourceAddress.resolveOperationURLFromClass(resourceClass, name, ps);
|
||||
if (complex) {
|
||||
|
@ -426,7 +426,7 @@ public class ResourceAddress {
|
||||
} else {
|
||||
query = "";
|
||||
}
|
||||
query += httpParameterName + "=" + Utilities.encodeUri(parameters.get(httpParameterName));
|
||||
query += httpParameterName + "=" + Utilities.encodeUriParam(parameters.get(httpParameterName));
|
||||
}
|
||||
|
||||
return new URI(basePath.getScheme(), basePath.getUserInfo(), basePath.getHost(),basePath.getPort(), basePath.getPath(), query, basePath.getFragment());
|
||||
|
@ -16,6 +16,7 @@ import java.math.RoundingMode;
|
||||
import java.net.URI;
|
||||
import java.net.URLDecoder;
|
||||
import java.net.URLEncoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.StandardCopyOption;
|
||||
@ -926,11 +927,14 @@ public class Utilities {
|
||||
return parts.toArray(new String[]{});
|
||||
}
|
||||
|
||||
|
||||
public static String encodeUri(String v) {
|
||||
return v.replace("%", "%25").replace(" ", "%20").replace("?", "%3F").replace("=", "%3D").replace("|", "%7C").replace("+", "%2B");
|
||||
@Deprecated
|
||||
public static String encodeUri(String string) {
|
||||
return encodeUriParam(string);
|
||||
}
|
||||
|
||||
public static String encodeUriParam(String param) {
|
||||
return URLEncoder.encode(param, StandardCharsets.UTF_8);
|
||||
}
|
||||
|
||||
public static String normalize(String s) {
|
||||
if (noString(s))
|
||||
|
Loading…
x
Reference in New Issue
Block a user