Translated default field values are sanitized by i18n_field_translate_default(), which is the translate callback used for fields of type 'text'. However, the normal widget for text fields ('text_textfield') places the value in an input HTML element, where the value should not be sanitized.

Unfortunately, this does sort of reveal a weakness in the way translate callbacks are defined - they should really be per field WIDGET, not field TYPE. Anyway, rather than fully opening that can of worms, I'll just suggest for now that since the only widget for text fields (at least in core) is one that should not have its default value sanitized, this should be (not) done for all 'text' field types. Potentially, we could either do this OR check the widget in use (since the callback gets passed the instance settings which contain the widget to be used) so that other widgets could remain sanitized just in case - i.e. defaulting to sanitizing for the cases that we don't know about. See the attached patch.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

ptmkenny’s picture

Issue summary: View changes
Status: Active » Needs review
bgm’s picture

Status: Needs review » Reviewed & tested by the community

I also ran into this issue, and the patch fixed the problem. Thanks!

Jose Reyero’s picture

Status: Reviewed & tested by the community » Fixed

@james.williams,

this does sort of reveal a weakness in the way translate callbacks are defined - they should really be per field WIDGET, not field TYPE...

Right

Anyway, not really time for that, and this fixes the issue so committed, thanks,

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.