Class: CamaleonCms::CustomFieldsRelationship
- Inherits:
-
CamaleonRecord
- Object
- ActiveRecord::Base
- CamaleonRecord
- CamaleonCms::CustomFieldsRelationship
- Defined in:
- app/models/camaleon_cms/custom_fields_relationship.rb
Constant Summary collapse
- MARKUP_FIELD_KEYS =
Rendered positions that need a save-time gate (audit M17, scan-and-reject policy). An
editorvalue is emitted as markup (raw); afield_attrsvalue is a JSON pair whose members are emitted as markup; the URI field types are emitted into href/src. Every other field type's value renders through escaping ERB as element content, where markup cannot execute, so it needs no gate. %w[editor].freeze
- JSON_MARKUP_FIELD_KEYS =
%w[field_attrs].freeze
- URI_FIELD_KEYS =
%w[url image audio video file].freeze
- GATED_FIELD_KEYS =
(MARKUP_FIELD_KEYS + JSON_MARKUP_FIELD_KEYS + URI_FIELD_KEYS).freeze
Constants inherited from CamaleonRecord
CamaleonRecord::TRANSLATION_TAG_HIDE_MAP, CamaleonRecord::TRANSLATION_TAG_HIDE_REGEX, CamaleonRecord::TRANSLATION_TAG_HIDE_SENTINELS, CamaleonRecord::TRANSLATION_TAG_RESTORE_MAP, CamaleonRecord::TRANSLATION_TAG_RESTORE_REGEX
Instance Attribute Summary collapse
-
#unfiltered_value ⇒ Object
readonly
Opt-out for trusted server-side pipelines (imports, seeds, plugin code), mirroring Post#unfiltered_content!: a reader plus a bang enabler and NO writer, so mass assignment cannot reach it.
Class Method Summary collapse
-
.gate_rejection_reason(field_key, value) ⇒ Object
Why the save-time gate would refuse this value for the field type, or nil if it passes: :too_large (over the parse ceiling), :html (disallowed markup), :uri (script-capable URL).
-
.gated_field_key?(field_key) ⇒ Boolean
Whether this field type's value is emitted into a markup or URL position (so it is gated).
Instance Method Summary collapse
Methods inherited from CamaleonRecord
#ability, #cama_build_cache_key, #cama_fetch_cache, #cama_get_cache, #cama_remove_cache, cama_sanitize_translatable, #cama_set_cache, #can?, #current_site, #current_user, polymorphic_class_for, polymorphic_name, #reset_ability
Instance Attribute Details
#unfiltered_value ⇒ Object (readonly)
Opt-out for trusted server-side pipelines (imports, seeds, plugin code), mirroring Post#unfiltered_content!: a reader plus a bang enabler and NO writer, so mass assignment cannot reach it. Sticky for the lifetime of the instance.
34 35 36 |
# File 'app/models/camaleon_cms/custom_fields_relationship.rb', line 34 def unfiltered_value @unfiltered_value end |
Class Method Details
.gate_rejection_reason(field_key, value) ⇒ Object
Why the save-time gate would refuse this value for the field type, or nil if it passes: :too_large (over the parse ceiling), :html (disallowed markup), :uri (script-capable URL). Ignores author trust, so the validation (trust-gated) and the scan_content rake task (which reports every stored row) share one dispatch and cannot drift.
51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'app/models/camaleon_cms/custom_fields_relationship.rb', line 51 def gate_rejection_reason(field_key, value) return if value.blank? key = field_key.to_s if MARKUP_FIELD_KEYS.include?(key) markup_rejection_reason(value) elsif JSON_MARKUP_FIELD_KEYS.include?(key) return :too_large if CamaleonCms::UnsafeMarkup.too_large?(value) :html if json_member_values(value).any? { |member| markup_unsafe?(member) } elsif URI_FIELD_KEYS.include?(key) :uri if CamaleonCms::UnsafeMarkup.dangerous_uri?(value) end end |
.gated_field_key?(field_key) ⇒ Boolean
Whether this field type's value is emitted into a markup or URL position (so it is gated).
43 44 45 |
# File 'app/models/camaleon_cms/custom_fields_relationship.rb', line 43 def gated_field_key?(field_key) GATED_FIELD_KEYS.include?(field_key.to_s) end |
Instance Method Details
#unfiltered_value! ⇒ Object
36 37 38 39 |
# File 'app/models/camaleon_cms/custom_fields_relationship.rb', line 36 def unfiltered_value! @unfiltered_value = true self end |