Small validatin improvement
This commit is contained in:
@@ -28,7 +28,7 @@ const POST_MEDIA_THUMB_PATH = "web/static/media/posts/thumb"
|
|||||||
const MAX_THREAD_COUNT = 50
|
const MAX_THREAD_COUNT = 50
|
||||||
|
|
||||||
const MAX_BODY_LEN = 3000
|
const MAX_BODY_LEN = 3000
|
||||||
const MAX_SUBJECT_LEN = 100
|
const MAX_SUBJECT_LEN = 50
|
||||||
|
|
||||||
var SUPPORTED_IMAGE_MIME_TYPES = []string{"image/jpeg", "image/png", "image/gif", "image/webp"}
|
var SUPPORTED_IMAGE_MIME_TYPES = []string{"image/jpeg", "image/png", "image/gif", "image/webp"}
|
||||||
var SUPPORTED_VIDEO_MIME_TYPES = []string{"video/webm", "video/mp4", "video/ogg"}
|
var SUPPORTED_VIDEO_MIME_TYPES = []string{"video/webm", "video/mp4", "video/ogg"}
|
||||||
|
|||||||
+1
-1
@@ -165,7 +165,7 @@ func main() {
|
|||||||
body := strings.TrimSpace(r.FormValue("body"))
|
body := strings.TrimSpace(r.FormValue("body"))
|
||||||
|
|
||||||
if len(subject) > util.MAX_SUBJECT_LEN {
|
if len(subject) > util.MAX_SUBJECT_LEN {
|
||||||
http.Error(w, fmt.Sprintf("Subject exceeds %d characters", util.MAX_BODY_LEN), http.StatusBadRequest)
|
http.Error(w, fmt.Sprintf("Subject exceeds %d characters", util.MAX_SUBJECT_LEN), http.StatusBadRequest)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ package shared
|
|||||||
import "github.com/dominicf2001/comfychan/internal/database"
|
import "github.com/dominicf2001/comfychan/internal/database"
|
||||||
import "strings"
|
import "strings"
|
||||||
import "github.com/dominicf2001/comfychan/internal/util"
|
import "github.com/dominicf2001/comfychan/internal/util"
|
||||||
import "strconv"
|
|
||||||
|
|
||||||
templ NewPostForm(board database.Board, endpoint string, isForThread bool) {
|
templ NewPostForm(board database.Board, endpoint string, isForThread bool) {
|
||||||
<div style="display: none;" id="newPostWarning" class="warning"></div>
|
<div style="display: none;" id="newPostWarning" class="warning"></div>
|
||||||
@@ -37,11 +36,11 @@ templ NewPostForm(board database.Board, endpoint string, isForThread bool) {
|
|||||||
class="new-post-form-field"
|
class="new-post-form-field"
|
||||||
>
|
>
|
||||||
<th>Subject</th>
|
<th>Subject</th>
|
||||||
<td><input maxlength={ strconv.Itoa(util.MAX_SUBJECT_LEN) } id="newPostSubject" name="subject"/></td>
|
<td><input id="newPostSubject" name="subject"/></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr class="new-post-form-field">
|
<tr class="new-post-form-field">
|
||||||
<th>Comment</th>
|
<th>Comment</th>
|
||||||
<td><textarea maxlength={ strconv.Itoa(util.MAX_BODY_LEN) } id="newPostBody" name="body" required></textarea></td>
|
<td><textarea id="newPostBody" name="body" required></textarea></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr class="new-post-form-field">
|
<tr class="new-post-form-field">
|
||||||
<th>File</th>
|
<th>File</th>
|
||||||
|
|||||||
Reference in New Issue
Block a user