mirror of
https://github.com/outline/outline.git
synced 2026-11-21 05:24:03 +03:00
fix: Server error with invalid Prosemirror JSON should be validation error
This commit is contained in:
1 parent
e81f97b2de
commit
abb38ea447
1 file changed
+10
-4
@@ -22,10 +22,16 @@ export default function TextLength({
|
||||
addAttributeOptions(target, propertyName, {
|
||||
validate: {
|
||||
validLength(value: ProsemirrorData) {
|
||||
const text = ProsemirrorHelper.toPlainText(
|
||||
Node.fromJSON(schema, value),
|
||||
schema
|
||||
);
|
||||
let text;
|
||||
|
||||
try {
|
||||
text = ProsemirrorHelper.toPlainText(
|
||||
Node.fromJSON(schema, value),
|
||||
schema
|
||||
);
|
||||
} catch (err) {
|
||||
throw new Error("Invalid data");
|
||||
}
|
||||
|
||||
if (size(text) > max || size(text) < min) {
|
||||
throw new Error(msg);
|
||||
|
||||
Reference in new issue
Block a user