diff --git a/dispatcher/backend/src/common/schemas/fields.py b/dispatcher/backend/src/common/schemas/fields.py index 876ada4c..f3c909b0 100644 --- a/dispatcher/backend/src/common/schemas/fields.py +++ b/dispatcher/backend/src/common/schemas/fields.py @@ -47,6 +47,7 @@ def validate_schedule_name(value) -> bool: regex=r"^(.+?_)([a-z\-]{2,3}?_)(.+_|)([\d]{4}-[\d]{2}|{period}).zim$", error="ZIM filename format is incorrect", ) +validate_zim_title = validate.Length(max=30) validate_zim_description = validate.Length(max=80) validate_zim_longdescription = validate.Length(max=4000) diff --git a/dispatcher/backend/src/common/schemas/offliners/devdocs.py b/dispatcher/backend/src/common/schemas/offliners/devdocs.py index 3e0734d1..163cf772 100644 --- a/dispatcher/backend/src/common/schemas/offliners/devdocs.py +++ b/dispatcher/backend/src/common/schemas/offliners/devdocs.py @@ -5,6 +5,7 @@ validate_output, validate_zim_description, validate_zim_longdescription, + validate_zim_title, ) @@ -73,6 +74,7 @@ class Meta: "to `{full_name} Docs`", }, data_key="title-format", + validate=validate_zim_title, ) description_format = String( diff --git a/dispatcher/backend/src/common/schemas/offliners/freecodecamp.py b/dispatcher/backend/src/common/schemas/offliners/freecodecamp.py index 2f398e9b..1af7481a 100644 --- a/dispatcher/backend/src/common/schemas/offliners/freecodecamp.py +++ b/dispatcher/backend/src/common/schemas/offliners/freecodecamp.py @@ -6,6 +6,7 @@ validate_zim_description, validate_zim_filename, validate_zim_longdescription, + validate_zim_title, ) FCC_LANG_MAP = { @@ -59,6 +60,7 @@ class Meta: "description": "ZIM title", }, required=True, + validate=validate_zim_title, ) description = String( diff --git a/dispatcher/backend/src/common/schemas/offliners/gutenberg.py b/dispatcher/backend/src/common/schemas/offliners/gutenberg.py index 363d0beb..00099d18 100644 --- a/dispatcher/backend/src/common/schemas/offliners/gutenberg.py +++ b/dispatcher/backend/src/common/schemas/offliners/gutenberg.py @@ -1,7 +1,7 @@ from marshmallow import fields from common.schemas import SerializableSchema, String -from common.schemas.fields import validate_zim_description +from common.schemas.fields import validate_zim_description, validate_zim_title class GutenbergFlagsSchema(SerializableSchema): @@ -34,6 +34,7 @@ class Meta: "description": "Custom title for your project and ZIM.", }, data_key="zim-title", + validate=validate_zim_title, ) zim_desc = String( diff --git a/dispatcher/backend/src/common/schemas/offliners/ifixit.py b/dispatcher/backend/src/common/schemas/offliners/ifixit.py index 8719ec19..867aa1d6 100644 --- a/dispatcher/backend/src/common/schemas/offliners/ifixit.py +++ b/dispatcher/backend/src/common/schemas/offliners/ifixit.py @@ -5,6 +5,7 @@ validate_output, validate_zim_description, validate_zim_filename, + validate_zim_title, ) @@ -38,6 +39,7 @@ class Meta: "description": "Custom title for your ZIM. " "iFixIt homepage title otherwise", }, + validate=validate_zim_title, ) description = String( diff --git a/dispatcher/backend/src/common/schemas/offliners/kolibri.py b/dispatcher/backend/src/common/schemas/offliners/kolibri.py index fef7cc7e..0fce189b 100644 --- a/dispatcher/backend/src/common/schemas/offliners/kolibri.py +++ b/dispatcher/backend/src/common/schemas/offliners/kolibri.py @@ -6,6 +6,7 @@ validate_zim_description, validate_zim_filename, validate_zim_longdescription, + validate_zim_title, ) @@ -52,7 +53,8 @@ class Meta: metadata={ "label": "Title", "description": "Custom title for your ZIM. Kolibri channel name otherwise", - } + }, + validate=validate_zim_title, ) description = String( diff --git a/dispatcher/backend/src/common/schemas/offliners/mwoffliner.py b/dispatcher/backend/src/common/schemas/offliners/mwoffliner.py index 7a756295..a4f17d07 100644 --- a/dispatcher/backend/src/common/schemas/offliners/mwoffliner.py +++ b/dispatcher/backend/src/common/schemas/offliners/mwoffliner.py @@ -11,6 +11,7 @@ validate_output, validate_zim_description, validate_zim_longdescription, + validate_zim_title, ) @@ -59,7 +60,8 @@ class Meta: metadata={ "label": "ZIM Title", "description": "Custom ZIM title. Wiki name otherwise.", - } + }, + validate=validate_zim_title, ) customZimDescription = String( metadata={"label": "ZIM Description", "description": "Max length is 80 chars"}, diff --git a/dispatcher/backend/src/common/schemas/offliners/nautilus.py b/dispatcher/backend/src/common/schemas/offliners/nautilus.py index 19e24220..dbc5ca1a 100644 --- a/dispatcher/backend/src/common/schemas/offliners/nautilus.py +++ b/dispatcher/backend/src/common/schemas/offliners/nautilus.py @@ -5,6 +5,7 @@ validate_output, validate_zim_description, validate_zim_filename, + validate_zim_title, ) @@ -98,7 +99,8 @@ class Meta: metadata={ "label": "Title", "description": "Title for your project and ZIM. Otherwise --name.", - } + }, + validate=validate_zim_title, ) description = String( metadata={ diff --git a/dispatcher/backend/src/common/schemas/offliners/openedx.py b/dispatcher/backend/src/common/schemas/offliners/openedx.py index a19a02cd..1f54fffb 100644 --- a/dispatcher/backend/src/common/schemas/offliners/openedx.py +++ b/dispatcher/backend/src/common/schemas/offliners/openedx.py @@ -5,6 +5,7 @@ validate_output, validate_zim_description, validate_zim_filename, + validate_zim_title, ) @@ -174,6 +175,7 @@ class Meta: "description": "Custom title for your ZIM. Based on MOOC otherwise", }, data_key="title", + validate=validate_zim_title, ) description = String( diff --git a/dispatcher/backend/src/common/schemas/offliners/sotoki.py b/dispatcher/backend/src/common/schemas/offliners/sotoki.py index 29496c8e..aae10124 100644 --- a/dispatcher/backend/src/common/schemas/offliners/sotoki.py +++ b/dispatcher/backend/src/common/schemas/offliners/sotoki.py @@ -5,6 +5,7 @@ validate_output, validate_zim_description, validate_zim_filename, + validate_zim_title, ) @@ -33,6 +34,7 @@ class Meta: "label": "Title", "description": "Custom title for your ZIM. Site name otherwise", }, + validate=validate_zim_title, ) description = String( diff --git a/dispatcher/backend/src/common/schemas/offliners/ted.py b/dispatcher/backend/src/common/schemas/offliners/ted.py index 7bc17ef6..be1aba88 100644 --- a/dispatcher/backend/src/common/schemas/offliners/ted.py +++ b/dispatcher/backend/src/common/schemas/offliners/ted.py @@ -6,6 +6,7 @@ validate_zim_description, validate_zim_filename, validate_zim_longdescription, + validate_zim_title, ) @@ -111,7 +112,8 @@ class Meta: metadata={ "label": "Title", "description": "Custom title for your ZIM. Based on selection otherwise", - } + }, + validate=validate_zim_title, ) description = String( diff --git a/dispatcher/backend/src/common/schemas/offliners/wikihow.py b/dispatcher/backend/src/common/schemas/offliners/wikihow.py index 0e128436..48687562 100644 --- a/dispatcher/backend/src/common/schemas/offliners/wikihow.py +++ b/dispatcher/backend/src/common/schemas/offliners/wikihow.py @@ -5,6 +5,7 @@ validate_output, validate_zim_description, validate_zim_filename, + validate_zim_title, ) @@ -34,6 +35,7 @@ class Meta: "description": "Custom title for your ZIM. " "Wikihow homepage title otherwise", }, + validate=validate_zim_title, ) description = String( diff --git a/dispatcher/backend/src/common/schemas/offliners/youtube.py b/dispatcher/backend/src/common/schemas/offliners/youtube.py index 00cc3a33..b4f9f565 100644 --- a/dispatcher/backend/src/common/schemas/offliners/youtube.py +++ b/dispatcher/backend/src/common/schemas/offliners/youtube.py @@ -6,6 +6,7 @@ validate_zim_description, validate_zim_filename, validate_zim_longdescription, + validate_zim_title, ) @@ -85,7 +86,8 @@ class Meta: "label": "ZIM Title", "description": "Custom title for your ZIM. " "Default to Channel name (of first video if playlists)", - } + }, + validate=validate_zim_title, ) description = String( diff --git a/dispatcher/backend/src/common/schemas/offliners/zimit.py b/dispatcher/backend/src/common/schemas/offliners/zimit.py index 07ed9003..c7686a5f 100644 --- a/dispatcher/backend/src/common/schemas/offliners/zimit.py +++ b/dispatcher/backend/src/common/schemas/offliners/zimit.py @@ -5,6 +5,7 @@ validate_output, validate_zim_description, validate_zim_filename, + validate_zim_title, ) # https://github.com/puppeteer/puppeteer/blob/main/src/common/DeviceDescriptors.ts @@ -175,7 +176,8 @@ class Meta: metadata={ "label": "Title", "description": "Custom title for ZIM. Defaults to title of main page", - } + }, + validate=validate_zim_title, ) description = String(