systopia / de.systopia.moregreetings

CiviCRM Extension for additional greetings
GNU Affero General Public License v3.0
4 stars 10 forks source link

Render greetings without newlines and multiple spaces (HTML-like stripping) #11

Closed jensschuppe closed 5 years ago

jensschuppe commented 5 years ago

Formatting your Smarty logic with newlines and spaces causes those characters being rendered within the greeting. This is not a prolem in an HTML context, but causes a mess when e.g. exporting those fields or using the associated tokens in non-HTML templates.

MoreGreetings should apply a strip logic that removes newline characters altogether (since those are being interpreted differently in HTML and non-HTML contexts) and merge multiple spaces to only one.

Note: Smarty's {strip} can not be used, since it strips all spaces outside of HTML tags, which aren't allowed in MoreGreetings anyway.

jensschuppe commented 5 years ago

98ef158c985d25fc11357fda70cfe58914a62582 works for new greeting values but will not update existing values with newlines and excess white spaces, since the old values are being retrieved using the Contact.get API, which returns an already trimmed version of the raw value; moregreetings will thus not update the value, since it compares both trimmed versions.

Ergo: There needs to be an Upgrader scanning through all raw (!) values and updating them as needed. This may be, however, quite time consuming as an upgrade task. There is currently no way to force-update greeting values, however.

jensschuppe commented 5 years ago

My previous comment seems to not be true (anymore?).

Discussed with @bjendres that cleaning values before writing to the database should be made dependent on a global setting in the moregreetings extension.

bjendres commented 5 years ago

Closed this ticket in favour of #12