simple-module-core 0.0.48__tar.gz → 0.0.49__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {simple_module_core-0.0.48 → simple_module_core-0.0.49}/PKG-INFO +1 -1
- {simple_module_core-0.0.48 → simple_module_core-0.0.49}/pyproject.toml +1 -1
- simple_module_core-0.0.49/simple_module_core/_mail_headers.py +47 -0
- {simple_module_core-0.0.48 → simple_module_core-0.0.49}/simple_module_core/mail.py +5 -1
- simple_module_core-0.0.49/tests/test_mail_headers.py +94 -0
- {simple_module_core-0.0.48 → simple_module_core-0.0.49}/.gitignore +0 -0
- {simple_module_core-0.0.48 → simple_module_core-0.0.49}/LICENSE +0 -0
- {simple_module_core-0.0.48 → simple_module_core-0.0.49}/README.md +0 -0
- {simple_module_core-0.0.48 → simple_module_core-0.0.49}/simple_module_core/__init__.py +0 -0
- {simple_module_core-0.0.48 → simple_module_core-0.0.49}/simple_module_core/__main__.py +0 -0
- {simple_module_core-0.0.48 → simple_module_core-0.0.49}/simple_module_core/_auth_providers.py +0 -0
- {simple_module_core-0.0.48 → simple_module_core-0.0.49}/simple_module_core/_data_doctor.py +0 -0
- {simple_module_core-0.0.48 → simple_module_core-0.0.49}/simple_module_core/_entry_point_errors.py +0 -0
- {simple_module_core-0.0.48 → simple_module_core-0.0.49}/simple_module_core/_i18n_flatten.py +0 -0
- {simple_module_core-0.0.48 → simple_module_core-0.0.49}/simple_module_core/_i18n_translator.py +0 -0
- {simple_module_core-0.0.48 → simple_module_core-0.0.49}/simple_module_core/_invalidation_message.py +0 -0
- {simple_module_core-0.0.48 → simple_module_core-0.0.49}/simple_module_core/_migration_doctor.py +0 -0
- {simple_module_core-0.0.48 → simple_module_core-0.0.49}/simple_module_core/_module_conventions.py +0 -0
- {simple_module_core-0.0.48 → simple_module_core-0.0.49}/simple_module_core/_module_ordering.py +0 -0
- {simple_module_core-0.0.48 → simple_module_core-0.0.49}/simple_module_core/_permission_grants.py +0 -0
- {simple_module_core-0.0.48 → simple_module_core-0.0.49}/simple_module_core/_request_hooks.py +0 -0
- {simple_module_core-0.0.48 → simple_module_core-0.0.49}/simple_module_core/activity_feed.py +0 -0
- {simple_module_core-0.0.48 → simple_module_core-0.0.49}/simple_module_core/admin_surface.py +0 -0
- {simple_module_core-0.0.48 → simple_module_core-0.0.49}/simple_module_core/app_state.py +0 -0
- {simple_module_core-0.0.48 → simple_module_core-0.0.49}/simple_module_core/audit_links.py +0 -0
- {simple_module_core-0.0.48 → simple_module_core-0.0.49}/simple_module_core/body_limits.py +0 -0
- {simple_module_core-0.0.48 → simple_module_core-0.0.49}/simple_module_core/correlation.py +0 -0
- {simple_module_core-0.0.48 → simple_module_core-0.0.49}/simple_module_core/cors.py +0 -0
- {simple_module_core-0.0.48 → simple_module_core-0.0.49}/simple_module_core/crypto.py +0 -0
- {simple_module_core-0.0.48 → simple_module_core-0.0.49}/simple_module_core/csp.py +0 -0
- {simple_module_core-0.0.48 → simple_module_core-0.0.49}/simple_module_core/data_compatibility.py +0 -0
- {simple_module_core-0.0.48 → simple_module_core-0.0.49}/simple_module_core/datetimes.py +0 -0
- {simple_module_core-0.0.48 → simple_module_core-0.0.49}/simple_module_core/deprecation.py +0 -0
- {simple_module_core-0.0.48 → simple_module_core-0.0.49}/simple_module_core/design_packs.py +0 -0
- {simple_module_core-0.0.48 → simple_module_core-0.0.49}/simple_module_core/diagnostics/__init__.py +0 -0
- {simple_module_core-0.0.48 → simple_module_core-0.0.49}/simple_module_core/diagnostics/_auth.py +0 -0
- {simple_module_core-0.0.48 → simple_module_core-0.0.49}/simple_module_core/diagnostics/_coupling.py +0 -0
- {simple_module_core-0.0.48 → simple_module_core-0.0.49}/simple_module_core/diagnostics/_css.py +0 -0
- {simple_module_core-0.0.48 → simple_module_core-0.0.49}/simple_module_core/diagnostics/_db_extensions.py +0 -0
- {simple_module_core-0.0.48 → simple_module_core-0.0.49}/simple_module_core/diagnostics/_dependencies.py +0 -0
- {simple_module_core-0.0.48 → simple_module_core-0.0.49}/simple_module_core/diagnostics/_durable_names.py +0 -0
- {simple_module_core-0.0.48 → simple_module_core-0.0.49}/simple_module_core/diagnostics/_expression_index.py +0 -0
- {simple_module_core-0.0.48 → simple_module_core-0.0.49}/simple_module_core/diagnostics/_heavy_task_imports.py +0 -0
- {simple_module_core-0.0.48 → simple_module_core-0.0.49}/simple_module_core/diagnostics/_i18n.py +0 -0
- {simple_module_core-0.0.48 → simple_module_core-0.0.49}/simple_module_core/diagnostics/_inertia_api.py +0 -0
- {simple_module_core-0.0.48 → simple_module_core-0.0.49}/simple_module_core/diagnostics/_js_workspace.py +0 -0
- {simple_module_core-0.0.48 → simple_module_core-0.0.49}/simple_module_core/diagnostics/_migration.py +0 -0
- {simple_module_core-0.0.48 → simple_module_core-0.0.49}/simple_module_core/diagnostics/_module.py +0 -0
- {simple_module_core-0.0.48 → simple_module_core-0.0.49}/simple_module_core/diagnostics/_pages.py +0 -0
- {simple_module_core-0.0.48 → simple_module_core-0.0.49}/simple_module_core/diagnostics/_runner.py +0 -0
- {simple_module_core-0.0.48 → simple_module_core-0.0.49}/simple_module_core/diagnostics/_spa_mount.py +0 -0
- {simple_module_core-0.0.48 → simple_module_core-0.0.49}/simple_module_core/diagnostics/_tenancy.py +0 -0
- {simple_module_core-0.0.48 → simple_module_core-0.0.49}/simple_module_core/diagnostics/_types.py +0 -0
- {simple_module_core-0.0.48 → simple_module_core-0.0.49}/simple_module_core/discovery.py +0 -0
- {simple_module_core-0.0.48 → simple_module_core-0.0.49}/simple_module_core/dotenv.py +0 -0
- {simple_module_core-0.0.48 → simple_module_core-0.0.49}/simple_module_core/durable_events.py +0 -0
- {simple_module_core-0.0.48 → simple_module_core-0.0.49}/simple_module_core/environments.py +0 -0
- {simple_module_core-0.0.48 → simple_module_core-0.0.49}/simple_module_core/events.py +0 -0
- {simple_module_core-0.0.48 → simple_module_core-0.0.49}/simple_module_core/exceptions.py +0 -0
- {simple_module_core-0.0.48 → simple_module_core-0.0.49}/simple_module_core/feature_flags.py +0 -0
- {simple_module_core-0.0.48 → simple_module_core-0.0.49}/simple_module_core/file_access.py +0 -0
- {simple_module_core-0.0.48 → simple_module_core-0.0.49}/simple_module_core/health.py +0 -0
- {simple_module_core-0.0.48 → simple_module_core-0.0.49}/simple_module_core/i18n.py +0 -0
- {simple_module_core-0.0.48 → simple_module_core-0.0.49}/simple_module_core/i18n_overrides.py +0 -0
- {simple_module_core-0.0.48 → simple_module_core-0.0.49}/simple_module_core/invalidation.py +0 -0
- {simple_module_core-0.0.48 → simple_module_core-0.0.49}/simple_module_core/invalidation_refresh.py +0 -0
- {simple_module_core-0.0.48 → simple_module_core-0.0.49}/simple_module_core/leases.py +0 -0
- {simple_module_core-0.0.48 → simple_module_core-0.0.49}/simple_module_core/menu.py +0 -0
- {simple_module_core-0.0.48 → simple_module_core-0.0.49}/simple_module_core/migration_support/__init__.py +0 -0
- {simple_module_core-0.0.48 → simple_module_core-0.0.49}/simple_module_core/module.py +0 -0
- {simple_module_core-0.0.48 → simple_module_core-0.0.49}/simple_module_core/module_meta.py +0 -0
- {simple_module_core-0.0.48 → simple_module_core-0.0.49}/simple_module_core/module_settings.py +0 -0
- {simple_module_core-0.0.48 → simple_module_core-0.0.49}/simple_module_core/path_rules.py +0 -0
- {simple_module_core-0.0.48 → simple_module_core-0.0.49}/simple_module_core/permission_catalogue.py +0 -0
- {simple_module_core-0.0.48 → simple_module_core-0.0.49}/simple_module_core/permission_denied.py +0 -0
- {simple_module_core-0.0.48 → simple_module_core-0.0.49}/simple_module_core/permissions.py +0 -0
- {simple_module_core-0.0.48 → simple_module_core-0.0.49}/simple_module_core/principal_permissions.py +0 -0
- {simple_module_core-0.0.48 → simple_module_core-0.0.49}/simple_module_core/principals.py +0 -0
- {simple_module_core-0.0.48 → simple_module_core-0.0.49}/simple_module_core/public_routes.py +0 -0
- {simple_module_core-0.0.48 → simple_module_core-0.0.49}/simple_module_core/py.typed +0 -0
- {simple_module_core-0.0.48 → simple_module_core-0.0.49}/simple_module_core/rate_limit.py +0 -0
- {simple_module_core-0.0.48 → simple_module_core-0.0.49}/simple_module_core/redirect_safety.py +0 -0
- {simple_module_core-0.0.48 → simple_module_core-0.0.49}/simple_module_core/resources.py +0 -0
- {simple_module_core-0.0.48 → simple_module_core-0.0.49}/simple_module_core/role_directory.py +0 -0
- {simple_module_core-0.0.48 → simple_module_core-0.0.49}/simple_module_core/secret_fields.py +0 -0
- {simple_module_core-0.0.48 → simple_module_core-0.0.49}/simple_module_core/services.py +0 -0
- {simple_module_core-0.0.48 → simple_module_core-0.0.49}/simple_module_core/settings_base.py +0 -0
- {simple_module_core-0.0.48 → simple_module_core-0.0.49}/simple_module_core/settings_hydrate.py +0 -0
- {simple_module_core-0.0.48 → simple_module_core-0.0.49}/simple_module_core/setup_steps.py +0 -0
- {simple_module_core-0.0.48 → simple_module_core-0.0.49}/simple_module_core/singleflight.py +0 -0
- {simple_module_core-0.0.48 → simple_module_core-0.0.49}/simple_module_core/spa_mount.py +0 -0
- {simple_module_core-0.0.48 → simple_module_core-0.0.49}/simple_module_core/stored_settings.py +0 -0
- {simple_module_core-0.0.48 → simple_module_core-0.0.49}/simple_module_core/tenancy.py +0 -0
- {simple_module_core-0.0.48 → simple_module_core-0.0.49}/simple_module_core/tenant_events.py +0 -0
- {simple_module_core-0.0.48 → simple_module_core-0.0.49}/simple_module_core/user_directory.py +0 -0
- {simple_module_core-0.0.48 → simple_module_core-0.0.49}/simple_module_core/user_events.py +0 -0
- {simple_module_core-0.0.48 → simple_module_core-0.0.49}/simple_module_core/versioning.py +0 -0
- {simple_module_core-0.0.48 → simple_module_core-0.0.49}/tests/test_admin_surface.py +0 -0
- {simple_module_core-0.0.48 → simple_module_core-0.0.49}/tests/test_admin_surface_diagnostics.py +0 -0
- {simple_module_core-0.0.48 → simple_module_core-0.0.49}/tests/test_audit_links.py +0 -0
- {simple_module_core-0.0.48 → simple_module_core-0.0.49}/tests/test_auth_provider_capability.py +0 -0
- {simple_module_core-0.0.48 → simple_module_core-0.0.49}/tests/test_auth_provider_selection.py +0 -0
- {simple_module_core-0.0.48 → simple_module_core-0.0.49}/tests/test_core_app_state.py +0 -0
- {simple_module_core-0.0.48 → simple_module_core-0.0.49}/tests/test_core_data_compatibility_doctor.py +0 -0
- {simple_module_core-0.0.48 → simple_module_core-0.0.49}/tests/test_core_datetimes.py +0 -0
- {simple_module_core-0.0.48 → simple_module_core-0.0.49}/tests/test_core_discovery_stale_sys_path.py +0 -0
- {simple_module_core-0.0.48 → simple_module_core-0.0.49}/tests/test_core_inline_delivery_context.py +0 -0
- {simple_module_core-0.0.48 → simple_module_core-0.0.49}/tests/test_core_invalidation_refresh.py +0 -0
- {simple_module_core-0.0.48 → simple_module_core-0.0.49}/tests/test_core_leases.py +0 -0
- {simple_module_core-0.0.48 → simple_module_core-0.0.49}/tests/test_core_lifecycle_docs.py +0 -0
- {simple_module_core-0.0.48 → simple_module_core-0.0.49}/tests/test_core_mail_resolution.py +0 -0
- {simple_module_core-0.0.48 → simple_module_core-0.0.49}/tests/test_core_module_settings.py +0 -0
- {simple_module_core-0.0.48 → simple_module_core-0.0.49}/tests/test_core_role_directory.py +0 -0
- {simple_module_core-0.0.48 → simple_module_core-0.0.49}/tests/test_core_settings_source_cache.py +0 -0
- {simple_module_core-0.0.48 → simple_module_core-0.0.49}/tests/test_core_singleflight.py +0 -0
- {simple_module_core-0.0.48 → simple_module_core-0.0.49}/tests/test_core_user_directory.py +0 -0
- {simple_module_core-0.0.48 → simple_module_core-0.0.49}/tests/test_csp_registry.py +0 -0
- {simple_module_core-0.0.48 → simple_module_core-0.0.49}/tests/test_css_diagnostics.py +0 -0
- {simple_module_core-0.0.48 → simple_module_core-0.0.49}/tests/test_css_scanner.py +0 -0
- {simple_module_core-0.0.48 → simple_module_core-0.0.49}/tests/test_db_extensions_diagnostics.py +0 -0
- {simple_module_core-0.0.48 → simple_module_core-0.0.49}/tests/test_deprecation_helper.py +0 -0
- {simple_module_core-0.0.48 → simple_module_core-0.0.49}/tests/test_design_packs.py +0 -0
- {simple_module_core-0.0.48 → simple_module_core-0.0.49}/tests/test_diagnostics.py +0 -0
- {simple_module_core-0.0.48 → simple_module_core-0.0.49}/tests/test_diagnostics_encoding.py +0 -0
- {simple_module_core-0.0.48 → simple_module_core-0.0.49}/tests/test_diagnostics_fd_output.py +0 -0
- {simple_module_core-0.0.48 → simple_module_core-0.0.49}/tests/test_diagnostics_output.py +0 -0
- {simple_module_core-0.0.48 → simple_module_core-0.0.49}/tests/test_diagnostics_tenancy.py +0 -0
- {simple_module_core-0.0.48 → simple_module_core-0.0.49}/tests/test_discovery.py +0 -0
- {simple_module_core-0.0.48 → simple_module_core-0.0.49}/tests/test_discovery_missing_deps.py +0 -0
- {simple_module_core-0.0.48 → simple_module_core-0.0.49}/tests/test_discovery_selection.py +0 -0
- {simple_module_core-0.0.48 → simple_module_core-0.0.49}/tests/test_doctor_cli_overrides.py +0 -0
- {simple_module_core-0.0.48 → simple_module_core-0.0.49}/tests/test_dotenv.py +0 -0
- {simple_module_core-0.0.48 → simple_module_core-0.0.49}/tests/test_durable_events.py +0 -0
- {simple_module_core-0.0.48 → simple_module_core-0.0.49}/tests/test_environments.py +0 -0
- {simple_module_core-0.0.48 → simple_module_core-0.0.49}/tests/test_events.py +0 -0
- {simple_module_core-0.0.48 → simple_module_core-0.0.49}/tests/test_events_inline.py +0 -0
- {simple_module_core-0.0.48 → simple_module_core-0.0.49}/tests/test_expression_index_diagnostics.py +0 -0
- {simple_module_core-0.0.48 → simple_module_core-0.0.49}/tests/test_feature_flags.py +0 -0
- {simple_module_core-0.0.48 → simple_module_core-0.0.49}/tests/test_feature_flags_decorator.py +0 -0
- {simple_module_core-0.0.48 → simple_module_core-0.0.49}/tests/test_health_registry.py +0 -0
- {simple_module_core-0.0.48 → simple_module_core-0.0.49}/tests/test_heavy_task_imports_diagnostics.py +0 -0
- {simple_module_core-0.0.48 → simple_module_core-0.0.49}/tests/test_i18n.py +0 -0
- {simple_module_core-0.0.48 → simple_module_core-0.0.49}/tests/test_i18n_diagnostics.py +0 -0
- {simple_module_core-0.0.48 → simple_module_core-0.0.49}/tests/test_i18n_overrides.py +0 -0
- {simple_module_core-0.0.48 → simple_module_core-0.0.49}/tests/test_invalidation.py +0 -0
- {simple_module_core-0.0.48 → simple_module_core-0.0.49}/tests/test_invalidation_dedup.py +0 -0
- {simple_module_core-0.0.48 → simple_module_core-0.0.49}/tests/test_invalidation_handlers.py +0 -0
- {simple_module_core-0.0.48 → simple_module_core-0.0.49}/tests/test_key_derivation.py +0 -0
- {simple_module_core-0.0.48 → simple_module_core-0.0.49}/tests/test_mail_attachments.py +0 -0
- {simple_module_core-0.0.48 → simple_module_core-0.0.49}/tests/test_mail_reply_to.py +0 -0
- {simple_module_core-0.0.48 → simple_module_core-0.0.49}/tests/test_menu.py +0 -0
- {simple_module_core-0.0.48 → simple_module_core-0.0.49}/tests/test_module_base.py +0 -0
- {simple_module_core-0.0.48 → simple_module_core-0.0.49}/tests/test_module_defaults.py +0 -0
- {simple_module_core-0.0.48 → simple_module_core-0.0.49}/tests/test_module_diagnostics.py +0 -0
- {simple_module_core-0.0.48 → simple_module_core-0.0.49}/tests/test_module_discovery_versions.py +0 -0
- {simple_module_core-0.0.48 → simple_module_core-0.0.49}/tests/test_module_package_conventions.py +0 -0
- {simple_module_core-0.0.48 → simple_module_core-0.0.49}/tests/test_path_rule_registries.py +0 -0
- {simple_module_core-0.0.48 → simple_module_core-0.0.49}/tests/test_permission_catalogue.py +0 -0
- {simple_module_core-0.0.48 → simple_module_core-0.0.49}/tests/test_permission_sources.py +0 -0
- {simple_module_core-0.0.48 → simple_module_core-0.0.49}/tests/test_permissions.py +0 -0
- {simple_module_core-0.0.48 → simple_module_core-0.0.49}/tests/test_permissions_admin_principal.py +0 -0
- {simple_module_core-0.0.48 → simple_module_core-0.0.49}/tests/test_principal_composition.py +0 -0
- {simple_module_core-0.0.48 → simple_module_core-0.0.49}/tests/test_public_routes.py +0 -0
- {simple_module_core-0.0.48 → simple_module_core-0.0.49}/tests/test_public_routes_rate_precedence.py +0 -0
- {simple_module_core-0.0.48 → simple_module_core-0.0.49}/tests/test_redirect_safety.py +0 -0
- {simple_module_core-0.0.48 → simple_module_core-0.0.49}/tests/test_registry_overrides.py +0 -0
- {simple_module_core-0.0.48 → simple_module_core-0.0.49}/tests/test_services.py +0 -0
- {simple_module_core-0.0.48 → simple_module_core-0.0.49}/tests/test_settings_base.py +0 -0
- {simple_module_core-0.0.48 → simple_module_core-0.0.49}/tests/test_sm003_page_render.py +0 -0
- {simple_module_core-0.0.48 → simple_module_core-0.0.49}/tests/test_sm009_dynamic_coupling.py +0 -0
- {simple_module_core-0.0.48 → simple_module_core-0.0.49}/tests/test_sm034_durable_names.py +0 -0
- {simple_module_core-0.0.48 → simple_module_core-0.0.49}/tests/test_tenant_exists.py +0 -0
- {simple_module_core-0.0.48 → simple_module_core-0.0.49}/tests/test_tenant_roles.py +0 -0
- {simple_module_core-0.0.48 → simple_module_core-0.0.49}/tests/test_versioning.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: simple_module_core
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.49
|
|
4
4
|
Summary: Module-system primitives for the simple_module framework — ModuleBase, discovery, diagnostics, events
|
|
5
5
|
Project-URL: Homepage, https://github.com/antosubash/simple_module_python
|
|
6
6
|
Project-URL: Repository, https://github.com/antosubash/simple_module_python
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"""Validation shared by mail messages and transports."""
|
|
2
|
+
|
|
3
|
+
import re
|
|
4
|
+
|
|
5
|
+
_HEADER_NAME = re.compile(r"[!-9;-~]{1,997}")
|
|
6
|
+
_UNSAFE_VALUE = re.compile(r"[\x00-\x08\x0a-\x1f\x7f-\x9f\u2028\u2029]")
|
|
7
|
+
_RESERVED_HEADERS = frozenset(
|
|
8
|
+
{
|
|
9
|
+
"from",
|
|
10
|
+
"to",
|
|
11
|
+
"cc",
|
|
12
|
+
"bcc",
|
|
13
|
+
"subject",
|
|
14
|
+
"reply-to",
|
|
15
|
+
"date",
|
|
16
|
+
"message-id",
|
|
17
|
+
"mime-version",
|
|
18
|
+
"sender",
|
|
19
|
+
"return-path",
|
|
20
|
+
"received",
|
|
21
|
+
"received-spf",
|
|
22
|
+
"dkim-signature",
|
|
23
|
+
"authentication-results",
|
|
24
|
+
"delivered-to",
|
|
25
|
+
"envelope-to",
|
|
26
|
+
"envelope-from",
|
|
27
|
+
}
|
|
28
|
+
)
|
|
29
|
+
|
|
30
|
+
# Routing, authentication and delivery trace fields belong to the transport/MTA.
|
|
31
|
+
_RESERVED_PREFIXES = ("content-", "resent-", "arc-", "x-original-", "x-delivered-", "x-envelope-")
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def validate_mail_headers(headers: dict[str, str]) -> dict[str, str]:
|
|
35
|
+
"""Copy custom headers, excluding transport/MTA fields and control characters."""
|
|
36
|
+
for name, value in headers.items():
|
|
37
|
+
if not isinstance(name, str) or not _HEADER_NAME.fullmatch(name):
|
|
38
|
+
raise ValueError(
|
|
39
|
+
"mail header names must be 1-997 ASCII characters without spaces or colons"
|
|
40
|
+
)
|
|
41
|
+
if name.lower() in _RESERVED_HEADERS or name.lower().startswith(_RESERVED_PREFIXES):
|
|
42
|
+
raise ValueError(f"mail header {name!r} is owned by the sender")
|
|
43
|
+
if not isinstance(value, str) or _UNSAFE_VALUE.search(value):
|
|
44
|
+
raise ValueError(
|
|
45
|
+
"mail header values must be strings without controls other than horizontal tab"
|
|
46
|
+
)
|
|
47
|
+
return dict(headers)
|
|
@@ -18,7 +18,7 @@ import base64
|
|
|
18
18
|
import logging
|
|
19
19
|
import re
|
|
20
20
|
from collections.abc import Awaitable, Callable, Sequence
|
|
21
|
-
from dataclasses import dataclass
|
|
21
|
+
from dataclasses import dataclass, field
|
|
22
22
|
from email import policy
|
|
23
23
|
from email.errors import HeaderParseError
|
|
24
24
|
from email.headerregistry import Address, Group
|
|
@@ -28,6 +28,8 @@ from typing import Annotated, Any, Protocol, runtime_checkable
|
|
|
28
28
|
from pydantic import BeforeValidator, ConfigDict, field_serializer, field_validator
|
|
29
29
|
from sqlmodel import SQLModel
|
|
30
30
|
|
|
31
|
+
from simple_module_core._mail_headers import validate_mail_headers
|
|
32
|
+
|
|
31
33
|
logger = logging.getLogger("simple_module.mail")
|
|
32
34
|
|
|
33
35
|
MAX_ATTACHMENT_BYTES = 10 * 1024 * 1024
|
|
@@ -160,8 +162,10 @@ class MailMessage:
|
|
|
160
162
|
Sequence[MailAttachment], BeforeValidator(_check_encoded_attachment_size)
|
|
161
163
|
] = ()
|
|
162
164
|
reply_to: str | None = None
|
|
165
|
+
headers: dict[str, str] = field(default_factory=dict)
|
|
163
166
|
|
|
164
167
|
def __post_init__(self) -> None:
|
|
168
|
+
object.__setattr__(self, "headers", validate_mail_headers(self.headers))
|
|
165
169
|
smtp_address_header(self.to)
|
|
166
170
|
if self.reply_to is not None:
|
|
167
171
|
_validate_reply_to(self.reply_to)
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
"""Custom mail headers are safe at construction and durable delivery (#1053)."""
|
|
2
|
+
|
|
3
|
+
import json
|
|
4
|
+
from dataclasses import dataclass
|
|
5
|
+
|
|
6
|
+
import pytest
|
|
7
|
+
from simple_module_core.durable_events import deserialize_event, serialize_event
|
|
8
|
+
from simple_module_core.events import Event
|
|
9
|
+
from simple_module_core.mail import MailMessage
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
@dataclass
|
|
13
|
+
class NewsletterReady(Event):
|
|
14
|
+
message: MailMessage
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
@pytest.mark.parametrize(
|
|
18
|
+
"name, value",
|
|
19
|
+
[
|
|
20
|
+
(name, "override")
|
|
21
|
+
for name in (
|
|
22
|
+
"From",
|
|
23
|
+
"to",
|
|
24
|
+
"CC",
|
|
25
|
+
"bCc",
|
|
26
|
+
"Subject",
|
|
27
|
+
"Reply-To",
|
|
28
|
+
"Date",
|
|
29
|
+
"Message-ID",
|
|
30
|
+
"Content-Type",
|
|
31
|
+
"content-transfer-encoding",
|
|
32
|
+
"CONTENT-anything",
|
|
33
|
+
"MIME-Version",
|
|
34
|
+
"Resent-To",
|
|
35
|
+
"rEsEnT-Date",
|
|
36
|
+
"Resent-From",
|
|
37
|
+
"Resent-Cc",
|
|
38
|
+
"Resent-Bcc",
|
|
39
|
+
"Resent-Sender",
|
|
40
|
+
"Sender",
|
|
41
|
+
"Return-Path",
|
|
42
|
+
"Received",
|
|
43
|
+
"Received-SPF",
|
|
44
|
+
"DKIM-Signature",
|
|
45
|
+
"ARC-Seal",
|
|
46
|
+
"arc-anything",
|
|
47
|
+
"Authentication-Results",
|
|
48
|
+
"X-Original-To",
|
|
49
|
+
"X-Original-From",
|
|
50
|
+
"Delivered-To",
|
|
51
|
+
"X-Delivered-To",
|
|
52
|
+
"Envelope-To",
|
|
53
|
+
"X-Envelope-From",
|
|
54
|
+
)
|
|
55
|
+
]
|
|
56
|
+
+ [
|
|
57
|
+
("X-Test\r\nBcc", "a@test"),
|
|
58
|
+
("X-Test\rBcc", "a@test"),
|
|
59
|
+
("X-Test\nBcc", "a@test"),
|
|
60
|
+
("X-Test", "ok\r\nBcc: a@test"),
|
|
61
|
+
("X-Test", "ok\rBcc: a@test"),
|
|
62
|
+
("X-Test", "ok\nBcc: a@test"),
|
|
63
|
+
("", "value"),
|
|
64
|
+
("X Test", "value"),
|
|
65
|
+
("X:Test", "value"),
|
|
66
|
+
("X" * 998, "value"),
|
|
67
|
+
*[("X-Test", f"before{control}after") for control in "\x00\v\f\x1b\x7f\x85\u2028\u2029"],
|
|
68
|
+
],
|
|
69
|
+
)
|
|
70
|
+
@pytest.mark.parametrize("durable", [False, True])
|
|
71
|
+
def test_reserved_or_unsafe_headers_are_rejected(name, value, durable) -> None:
|
|
72
|
+
fields = {"to": "a@test", "subject": "Hi", "text": "Body", "headers": {name: value}}
|
|
73
|
+
with pytest.raises(ValueError, match="header"):
|
|
74
|
+
if durable:
|
|
75
|
+
deserialize_event(NewsletterReady, {"message": fields})
|
|
76
|
+
else:
|
|
77
|
+
MailMessage(**fields)
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
@pytest.mark.parametrize("legacy", [False, True])
|
|
81
|
+
def test_headers_survive_durable_json_and_old_payloads_load(legacy) -> None:
|
|
82
|
+
headers = {"List-Unsubscribe": "<https://example.com/unsubscribe>"}
|
|
83
|
+
event = NewsletterReady(MailMessage("a@test", "Hi", "Body", headers=headers))
|
|
84
|
+
headers.clear()
|
|
85
|
+
payload = json.loads(json.dumps(serialize_event(event)))
|
|
86
|
+
assert payload["message"]["headers"] == {
|
|
87
|
+
"List-Unsubscribe": "<https://example.com/unsubscribe>"
|
|
88
|
+
}
|
|
89
|
+
if legacy:
|
|
90
|
+
del payload["message"]["headers"]
|
|
91
|
+
restored = deserialize_event(NewsletterReady, payload)
|
|
92
|
+
assert restored.message.headers == (
|
|
93
|
+
{} if legacy else {"List-Unsubscribe": "<https://example.com/unsubscribe>"}
|
|
94
|
+
)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{simple_module_core-0.0.48 → simple_module_core-0.0.49}/simple_module_core/_auth_providers.py
RENAMED
|
File without changes
|
|
File without changes
|
{simple_module_core-0.0.48 → simple_module_core-0.0.49}/simple_module_core/_entry_point_errors.py
RENAMED
|
File without changes
|
|
File without changes
|
{simple_module_core-0.0.48 → simple_module_core-0.0.49}/simple_module_core/_i18n_translator.py
RENAMED
|
File without changes
|
{simple_module_core-0.0.48 → simple_module_core-0.0.49}/simple_module_core/_invalidation_message.py
RENAMED
|
File without changes
|
{simple_module_core-0.0.48 → simple_module_core-0.0.49}/simple_module_core/_migration_doctor.py
RENAMED
|
File without changes
|
{simple_module_core-0.0.48 → simple_module_core-0.0.49}/simple_module_core/_module_conventions.py
RENAMED
|
File without changes
|
{simple_module_core-0.0.48 → simple_module_core-0.0.49}/simple_module_core/_module_ordering.py
RENAMED
|
File without changes
|
{simple_module_core-0.0.48 → simple_module_core-0.0.49}/simple_module_core/_permission_grants.py
RENAMED
|
File without changes
|
{simple_module_core-0.0.48 → simple_module_core-0.0.49}/simple_module_core/_request_hooks.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{simple_module_core-0.0.48 → simple_module_core-0.0.49}/simple_module_core/data_compatibility.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{simple_module_core-0.0.48 → simple_module_core-0.0.49}/simple_module_core/diagnostics/__init__.py
RENAMED
|
File without changes
|
{simple_module_core-0.0.48 → simple_module_core-0.0.49}/simple_module_core/diagnostics/_auth.py
RENAMED
|
File without changes
|
{simple_module_core-0.0.48 → simple_module_core-0.0.49}/simple_module_core/diagnostics/_coupling.py
RENAMED
|
File without changes
|
{simple_module_core-0.0.48 → simple_module_core-0.0.49}/simple_module_core/diagnostics/_css.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{simple_module_core-0.0.48 → simple_module_core-0.0.49}/simple_module_core/diagnostics/_i18n.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{simple_module_core-0.0.48 → simple_module_core-0.0.49}/simple_module_core/diagnostics/_migration.py
RENAMED
|
File without changes
|
{simple_module_core-0.0.48 → simple_module_core-0.0.49}/simple_module_core/diagnostics/_module.py
RENAMED
|
File without changes
|
{simple_module_core-0.0.48 → simple_module_core-0.0.49}/simple_module_core/diagnostics/_pages.py
RENAMED
|
File without changes
|
{simple_module_core-0.0.48 → simple_module_core-0.0.49}/simple_module_core/diagnostics/_runner.py
RENAMED
|
File without changes
|
{simple_module_core-0.0.48 → simple_module_core-0.0.49}/simple_module_core/diagnostics/_spa_mount.py
RENAMED
|
File without changes
|
{simple_module_core-0.0.48 → simple_module_core-0.0.49}/simple_module_core/diagnostics/_tenancy.py
RENAMED
|
File without changes
|
{simple_module_core-0.0.48 → simple_module_core-0.0.49}/simple_module_core/diagnostics/_types.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{simple_module_core-0.0.48 → simple_module_core-0.0.49}/simple_module_core/durable_events.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{simple_module_core-0.0.48 → simple_module_core-0.0.49}/simple_module_core/i18n_overrides.py
RENAMED
|
File without changes
|
|
File without changes
|
{simple_module_core-0.0.48 → simple_module_core-0.0.49}/simple_module_core/invalidation_refresh.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{simple_module_core-0.0.48 → simple_module_core-0.0.49}/simple_module_core/module_settings.py
RENAMED
|
File without changes
|
|
File without changes
|
{simple_module_core-0.0.48 → simple_module_core-0.0.49}/simple_module_core/permission_catalogue.py
RENAMED
|
File without changes
|
{simple_module_core-0.0.48 → simple_module_core-0.0.49}/simple_module_core/permission_denied.py
RENAMED
|
File without changes
|
|
File without changes
|
{simple_module_core-0.0.48 → simple_module_core-0.0.49}/simple_module_core/principal_permissions.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{simple_module_core-0.0.48 → simple_module_core-0.0.49}/simple_module_core/redirect_safety.py
RENAMED
|
File without changes
|
|
File without changes
|
{simple_module_core-0.0.48 → simple_module_core-0.0.49}/simple_module_core/role_directory.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{simple_module_core-0.0.48 → simple_module_core-0.0.49}/simple_module_core/settings_hydrate.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{simple_module_core-0.0.48 → simple_module_core-0.0.49}/simple_module_core/stored_settings.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{simple_module_core-0.0.48 → simple_module_core-0.0.49}/simple_module_core/user_directory.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{simple_module_core-0.0.48 → simple_module_core-0.0.49}/tests/test_admin_surface_diagnostics.py
RENAMED
|
File without changes
|
|
File without changes
|
{simple_module_core-0.0.48 → simple_module_core-0.0.49}/tests/test_auth_provider_capability.py
RENAMED
|
File without changes
|
{simple_module_core-0.0.48 → simple_module_core-0.0.49}/tests/test_auth_provider_selection.py
RENAMED
|
File without changes
|
|
File without changes
|
{simple_module_core-0.0.48 → simple_module_core-0.0.49}/tests/test_core_data_compatibility_doctor.py
RENAMED
|
File without changes
|
|
File without changes
|
{simple_module_core-0.0.48 → simple_module_core-0.0.49}/tests/test_core_discovery_stale_sys_path.py
RENAMED
|
File without changes
|
{simple_module_core-0.0.48 → simple_module_core-0.0.49}/tests/test_core_inline_delivery_context.py
RENAMED
|
File without changes
|
{simple_module_core-0.0.48 → simple_module_core-0.0.49}/tests/test_core_invalidation_refresh.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{simple_module_core-0.0.48 → simple_module_core-0.0.49}/tests/test_core_settings_source_cache.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{simple_module_core-0.0.48 → simple_module_core-0.0.49}/tests/test_db_extensions_diagnostics.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{simple_module_core-0.0.48 → simple_module_core-0.0.49}/tests/test_discovery_missing_deps.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{simple_module_core-0.0.48 → simple_module_core-0.0.49}/tests/test_expression_index_diagnostics.py
RENAMED
|
File without changes
|
|
File without changes
|
{simple_module_core-0.0.48 → simple_module_core-0.0.49}/tests/test_feature_flags_decorator.py
RENAMED
|
File without changes
|
|
File without changes
|
{simple_module_core-0.0.48 → simple_module_core-0.0.49}/tests/test_heavy_task_imports_diagnostics.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{simple_module_core-0.0.48 → simple_module_core-0.0.49}/tests/test_module_discovery_versions.py
RENAMED
|
File without changes
|
{simple_module_core-0.0.48 → simple_module_core-0.0.49}/tests/test_module_package_conventions.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{simple_module_core-0.0.48 → simple_module_core-0.0.49}/tests/test_permissions_admin_principal.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{simple_module_core-0.0.48 → simple_module_core-0.0.49}/tests/test_public_routes_rate_precedence.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{simple_module_core-0.0.48 → simple_module_core-0.0.49}/tests/test_sm009_dynamic_coupling.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|