I'm looking at the Handler classes page - http://drupal.org/node/1006990 - and expect that this is probably the best place to find how to figure out how to bring data through something like an auto-tagger or say HTMLPurifier.

I've imported the records, but I'd like to make sure that I've done some cleanup on the records because it would be foolish to assume that the legacy code was all valid HTML let alone xHTML or HTML5 code.

What are the best practices for scrubbing the data?

Comments

mikeryan’s picture

Version: 7.x-2.2-rc2 » 7.x-2.x-dev
Category: feature » support
Status: Active » Fixed

You can use callbacks on a field-by-field basis:

  $this->addFieldMapping('body', 'unscrubbed_text')
         ->callbacks(array($this, 'scrubText'));
...
  protected function scrubText($value) {
    // Scrub $value all you want
    ...
    return $value;
  }
mgifford’s picture

Thanks.. This could be really powerful when combined with something like #1430048: Sanitize programatically

For a simple test I decided to just strip the tags using:

  protected function scrubText($value) {
    // Test by removing all HTML tags
    $value = strip_tags($value);

    return $value;
  }

Sadly it didn't seem to strip all of the HTML tags. Not sure why. Have to look into this a bit more.

Status: Fixed » Closed (fixed)

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