mirror of
https://github.com/schollz/cowyo.git
synced 2023-08-10 21:13:00 +03:00
Make the max document length configurable
This commit is contained in:
parent
a976007642
commit
f86dc1095a
6
main.go
6
main.go
@ -57,6 +57,7 @@ func main() {
|
||||
c.GlobalBool("allow-insecure-markup"),
|
||||
c.GlobalBool("allow-file-uploads"),
|
||||
c.GlobalUint("max-upload-mb"),
|
||||
c.GlobalUint("max-document-length"),
|
||||
logger(c.GlobalBool("debug")),
|
||||
)
|
||||
return nil
|
||||
@ -143,6 +144,11 @@ func main() {
|
||||
Value: 2,
|
||||
Usage: "Largest file upload (in mb) allowed",
|
||||
},
|
||||
cli.UintFlag{
|
||||
Name: "max-document-length",
|
||||
Value: 100000000,
|
||||
Usage: "Largest wiki page (in characters) allowed",
|
||||
},
|
||||
}
|
||||
app.Commands = []cli.Command{
|
||||
{
|
||||
|
@ -38,7 +38,7 @@ type Site struct {
|
||||
Fileuploads bool
|
||||
MaxUploadSize uint
|
||||
Logger *lumber.ConsoleLogger
|
||||
|
||||
MaxDocumentSize uint // in runes; about a 10mb limit by default
|
||||
saveMut sync.Mutex
|
||||
sitemapUpToDate bool // TODO this makes everything use a pointer
|
||||
}
|
||||
@ -69,6 +69,7 @@ func Serve(
|
||||
allowInsecure bool,
|
||||
fileuploads bool,
|
||||
maxUploadSize uint,
|
||||
maxDocumentSize uint,
|
||||
logger *lumber.ConsoleLogger,
|
||||
) {
|
||||
var customCSS []byte
|
||||
@ -84,20 +85,19 @@ func Serve(
|
||||
}
|
||||
|
||||
router := Site{
|
||||
filepathToData,
|
||||
customCSS,
|
||||
defaultPage,
|
||||
defaultPassword,
|
||||
debounce,
|
||||
diary,
|
||||
sessions.NewCookieStore([]byte(secret)),
|
||||
secretCode,
|
||||
allowInsecure,
|
||||
fileuploads,
|
||||
maxUploadSize,
|
||||
logger,
|
||||
sync.Mutex{},
|
||||
false,
|
||||
PathToData: filepathToData,
|
||||
Css: customCSS,
|
||||
DefaultPage: defaultPage,
|
||||
DefaultPassword: defaultPassword,
|
||||
Debounce: debounce,
|
||||
Diary: diary,
|
||||
SessionStore: sessions.NewCookieStore([]byte(secret)),
|
||||
SecretCode: secretCode,
|
||||
AllowInsecure: allowInsecure,
|
||||
Fileuploads: fileuploads,
|
||||
MaxUploadSize: maxUploadSize,
|
||||
Logger: logger,
|
||||
MaxDocumentSize: maxDocumentSize,
|
||||
}.Router()
|
||||
|
||||
if TLS {
|
||||
@ -586,7 +586,7 @@ func (s *Site) handlePageUpdate(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, gin.H{"success": false, "message": "Wrong JSON"})
|
||||
return
|
||||
}
|
||||
if len(json.NewText) > 100000000 {
|
||||
if uint(len(json.NewText)) > s.MaxDocumentSize {
|
||||
c.JSON(http.StatusOK, gin.H{"success": false, "message": "Too much"})
|
||||
return
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user