mirror of
https://github.com/floci-io/floci.git
synced 2026-11-24 06:20:24 -05:00
fix(apigateway): decode the ~0 JSON Pointer escape in stage method-settings patch paths (#3526)
This commit is contained in:
1 parent
a6f1751dfb
commit
bc44fc9106
2 files changed
+36
-1
No files matched your search
+10
-1
@@ -735,7 +735,7 @@ public class ApiGatewayService {
|
||||
// AWS escapes the resource path's slashes as ~1 in the patch path ("/~1pets/GET/...")
|
||||
// but reports the setting keyed by the plain path ("pets/GET"), so normalise both the
|
||||
// escaped and unescaped spellings onto that one key.
|
||||
String resourcePath = prefix.substring(0, lastSlash).replace("~1", "/");
|
||||
String resourcePath = unescapeJsonPointer(prefix.substring(0, lastSlash));
|
||||
if (resourcePath.startsWith("/")) resourcePath = resourcePath.substring(1);
|
||||
String httpMethod = prefix.substring(lastSlash + 1);
|
||||
String methodKey = resourcePath + "/" + httpMethod;
|
||||
@@ -747,6 +747,15 @@ public class ApiGatewayService {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverses RFC 6901 JSON Pointer escaping: {@code ~1} is a literal {@code /} and {@code ~0} a
|
||||
* literal {@code ~}. The order matters: {@code ~1} must be decoded first so that {@code ~01}
|
||||
* (an escaped literal "~1") is not turned into a slash.
|
||||
*/
|
||||
static String unescapeJsonPointer(String segment) {
|
||||
return segment.replace("~1", "/").replace("~0", "~");
|
||||
}
|
||||
|
||||
private void applyMethodSettingValue(MethodSetting setting, String settingKey, String value) {
|
||||
if (value == null) return;
|
||||
switch (settingKey) {
|
||||
|
||||
Reference in new issue
Block a user