Skip to main content
Tweeted twitter.com/#!/StackDrupal/status/309929831066398720
edited tags
Link
avpaderno
  • 97.9k
  • 15
  • 164
  • 284
Source Link
Nick Tomlin
  • 550
  • 1
  • 4
  • 16

Sanitizing strings before adding as taxonomy term

I am programatically creating taxonomy terms from a JSON object. I have a simple script that iterates over the converted JSON, and creates a taxonomy hierarchy. Since these terms come from a client-generated CSV they have random spaces and characters in them I want to sanitize/normalize them before I add them using taxonomy_vocabulary_save()

I've looked at the list of drupal Sanitization Functions, but those all seem to deal with HTML/JS strings. Is there a drupal way for me to format these strings, or should I just use a PHP regex to do it?