forked from mtusi2026/mtusi2026lab3
Fixed
This commit is contained in:
@@ -12,7 +12,7 @@ def write(name, value):
|
|||||||
if path.exists():
|
if path.exists():
|
||||||
print('keep secrets/' + name)
|
print('keep secrets/' + name)
|
||||||
return path.read_text().strip()
|
return path.read_text().strip()
|
||||||
path.write_text(value + '\n', newline='\n')
|
path.write_bytes((value + '\n').encode('utf-8'))
|
||||||
print('created secrets/' + name)
|
print('created secrets/' + name)
|
||||||
return value
|
return value
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import (
|
|||||||
"crypto/sha256"
|
"crypto/sha256"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
|
"io"
|
||||||
"mime"
|
"mime"
|
||||||
"net/http"
|
"net/http"
|
||||||
"regexp"
|
"regexp"
|
||||||
@@ -60,8 +61,13 @@ func decodeJSON(w http.ResponseWriter, r *http.Request, dst any) *apperr.AppErro
|
|||||||
}
|
}
|
||||||
return apperr.InvalidRequest("malformed JSON body")
|
return apperr.InvalidRequest("malformed JSON body")
|
||||||
}
|
}
|
||||||
if dec.More() {
|
var extra json.RawMessage
|
||||||
return apperr.InvalidRequest("multiple JSON documents in body")
|
if err := dec.Decode(&extra); err != io.EOF {
|
||||||
|
var maxErr *http.MaxBytesError
|
||||||
|
if errors.As(err, &maxErr) {
|
||||||
|
return apperr.PayloadTooLarge("request body too large")
|
||||||
|
}
|
||||||
|
return apperr.InvalidRequest("malformed JSON body")
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user