Add post validation
このコミットが含まれているのは:
コミット
41ce8b4e9f
|
@ -101,6 +101,9 @@ function do_post() {
|
|||
$body = sanitize_post_body($body);
|
||||
$error_body = validate_post_body($body);
|
||||
}
|
||||
if (!$error_body && $thread_id !== NULL && !(ENABLE_IMAGE && $has_file)) {
|
||||
$error_body = validate_post_body_with_anchor($body);
|
||||
}
|
||||
|
||||
$errors = array_merge($error_title, $error_body);
|
||||
if ($errors) { return on_error(400, $errors); }
|
||||
|
|
|
@ -64,6 +64,13 @@ function validate_post_body($s) {
|
|||
return [];
|
||||
}
|
||||
|
||||
function validate_post_body_with_anchor($s) {
|
||||
// アンカーのみ(返信時のデフォルト)は不許可
|
||||
$s = preg_replace('/^>>[0-9]+/', '', $s);
|
||||
if (mbtrim($s) === '') { return ['アンカー「>>○○」1つだけの返信は不可。']; }
|
||||
return [];
|
||||
}
|
||||
|
||||
function sanitize_post_body($s) {
|
||||
return sanitize_multiline($s);
|
||||
}
|
||||
|
|
読み込み中…
新しいイシューから参照