Thursday, January 10, 2013

html encode/decode in drupal

Like all major CMS drupal stores text fields in encoded html format, to prevent cross site scripting attacks. Some times drupal does not process custom fields and encoded text is displayed as it is. I come across similar issue in my current project. I also post question on StackOverflow. While search for solution I come to know about decode_entities function. decode_entities converts html encoded text to more friendly text. Similary to encode special charters in text you can use check_plain.

decode_entities function
http://api.drupal.org/api/drupal/includes!unicode.inc/function/decode_entities/7

check_plain function
http://api.drupal.org/api/drupal/includes!bootstrap.inc/function/check_plain/7

My question on StackOverflow
http://stackoverflow.com/questions/14229641/rss-feeds-view-showing-encoded-special-character-in-title