fix storage issues
This commit is contained in:
@@ -420,39 +420,34 @@ parse_expression_attribute_values :: proc(request_body: []byte) -> (map[string]A
|
||||
return result, true
|
||||
}
|
||||
|
||||
// NOTE: changed from Maybe(string) -> (string, bool) so callers can use or_return.
|
||||
// ============================================================================
|
||||
// FIX: Use JSON object lookup instead of fragile string scanning.
|
||||
// This handles whitespace, field ordering, and escape sequences correctly.
|
||||
// ============================================================================
|
||||
parse_key_condition_expression_string :: proc(request_body: []byte) -> (expr: string, ok: bool) {
|
||||
body_str := string(request_body)
|
||||
data, parse_err := json.parse(request_body, allocator = context.temp_allocator)
|
||||
if parse_err != nil {
|
||||
return
|
||||
}
|
||||
defer json.destroy_value(data)
|
||||
|
||||
marker :: "\"KeyConditionExpression\""
|
||||
start_idx := strings.index(body_str, marker)
|
||||
if start_idx < 0 {
|
||||
root, root_ok := data.(json.Object)
|
||||
if !root_ok {
|
||||
return
|
||||
}
|
||||
|
||||
after_marker := body_str[start_idx + len(marker):]
|
||||
colon_idx := strings.index(after_marker, ":")
|
||||
if colon_idx < 0 {
|
||||
kce_val, found := root["KeyConditionExpression"]
|
||||
if !found {
|
||||
return
|
||||
}
|
||||
|
||||
rest := after_marker[colon_idx + 1:]
|
||||
quote_start := strings.index(rest, "\"")
|
||||
if quote_start < 0 {
|
||||
kce_str, str_ok := kce_val.(json.String)
|
||||
if !str_ok {
|
||||
return
|
||||
}
|
||||
|
||||
value_start := quote_start + 1
|
||||
pos := value_start
|
||||
for pos < len(rest) {
|
||||
if rest[pos] == '"' && (pos == 0 || rest[pos - 1] != '\\') {
|
||||
expr = rest[value_start:pos]
|
||||
ok = true
|
||||
return
|
||||
}
|
||||
pos += 1
|
||||
}
|
||||
|
||||
expr = string(kce_str)
|
||||
ok = true
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user