Restore validated Delamain manifest exports
This commit is contained in:
1 parent
527255f5b7
commit
02e1428ff6
2 files changed
+68
-14
No files matched your search
@@ -38,13 +38,13 @@ func (g *apiGuard) rememberExport(response *http.Response) error {
|
||||
response.Body = io.NopCloser(bytes.NewReader(body))
|
||||
|
||||
var result struct {
|
||||
TripID string `json:"trip_id"`
|
||||
Slot *uint64 `json:"note_slot"`
|
||||
Generation uint64 `json:"note_generation"`
|
||||
Size int `json:"note_size"`
|
||||
Data string `json:"data"`
|
||||
}
|
||||
if json.Unmarshal(body, &result) != nil || result.TripID == "" || result.Slot == nil ||
|
||||
tripID, _ := response.Request.Context().Value(exportSourceKey{}).(string)
|
||||
if json.Unmarshal(body, &result) != nil || !manifestTripID.MatchString(tripID) || result.Slot == nil ||
|
||||
result.Generation == 0 || result.Size != len(result.Data) || result.Size > 16<<10 {
|
||||
return nil
|
||||
}
|
||||
@@ -67,7 +67,7 @@ func (g *apiGuard) rememberExport(response *http.Response) error {
|
||||
delete(g.notes, oldestKey)
|
||||
}
|
||||
}
|
||||
g.notes[key] = exportedNote{tripID: result.TripID, data: result.Data, created: now}
|
||||
g.notes[key] = exportedNote{tripID: tripID, data: result.Data, created: now}
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user