Normalize unpaper_args to list at construction time
Use a Pydantic field validator to convert string input to list[str] during OcrOptions construction, simplifying the type from `str | list[str] | None` to `list[str] | None`. Security validation (path injection check) now happens at construction rather than in check_options_preprocessing().
This commit is contained in:
@@ -114,15 +114,8 @@ def check_options_preprocessing(options: OcrOptions) -> None:
|
||||
package='unpaper',
|
||||
version_checker=unpaper.version,
|
||||
need_version='6.1',
|
||||
required_for="--clean, --clean-final", # Problem arguments
|
||||
required_for="--clean, --clean-final",
|
||||
)
|
||||
try:
|
||||
if options.unpaper_args:
|
||||
options.unpaper_args = unpaper.validate_custom_args(
|
||||
options.unpaper_args
|
||||
)
|
||||
except Exception as e:
|
||||
raise BadArgsError("--unpaper-args: " + str(e)) from e
|
||||
|
||||
|
||||
def _check_plugin_invariant_options(options: OcrOptions) -> None:
|
||||
|
||||
Reference in New Issue
Block a user