Refactor usage of "handle_multiples" for Encode-plugin

Created on 8 April 2024, 6 months ago
Updated 29 April 2024, 5 months ago

Problem/Motivation

@kopeboy encountered an issue (see https://www.drupal.org/project/tamper/issues/3391096#comment-15541571 Create separate Decode-plugin RTBC ) when trying to base64-encode an array via a token. This isn't supported, but the Tamper-trait in eca_tamper still provides one because it's relying on the "handle_multiples" annotation-property of the underlying Tamper-plugin. See https://git.drupalcode.org/project/eca_tamper/-/blob/1.0.x/src/Plugin/Ta....

Steps to reproduce

Use the attached model to replicate the error.

Proposed resolution

Refactor the usage of "handle_multiples" OR create separate Tamper-Actions for the Encode-plugin (so not via the deriver)

Feature request
Status

Needs review

Version

2.0

Component

Code

Created by

🇧🇪Belgium lammensj

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @lammensj
  • 🇮🇹Italy kopeboy Milan

    Thank you for opening the issue. Although I should remark that the problem arises even by trying to encode simple strings, with or without token substitution, when the Conversion mode is "Base 64 Encode" (basically in that case we have a bug).

    Note that if we integrate with the latest Tamper with MR!20, which creates 2 separate actions, Encode and Decode (instead of a single Encode/Decode), we should also limit the Conversion mode options accordingly.

  • First commit to issue fork.
  • @jurgenhaas opened merge request.
  • Status changed to Needs review 5 months ago
  • 🇩🇪Germany jurgenhaas Gottmadingen

    The design around handle_multiples in the tamper module doesn't seem to be a type safe implementation, but we don't seem to be able to get that changed. So, instead of relying on that property, I've changed the approach to call the multiple() method of the tamper plugin to determine, whether we need to provide a string or an array.

    This affects the following plugins which declare the handles_multiple property:

    • ArrayFilter: requires an array
    • Encode: requires a string
    • Implode: requires a string
    • KeywordFilter: requires a string
    • Required: requires a string
    • Unique: requires an array

    I think, this is reasonable, except for the Implode plugin. From my point of view, that should get the multiple method to return TRUE.

Production build 0.71.5 2024