I have a CSV file from which I am importing some data. Should I need to apply XSS filter? How do I achieve this?

   while (!feof($handle)) {
    $data = fgetcsv($handle);
    $path[] = $data[0];
    $title[] = $data[1];
    $description[] = $data[2];
    $abstract[] = $data[3];
    $keywords[] = $data[4];

Well to my knowledge Drupal doesn't mind the input/import data that much, as long as it's rendered in a secure way.

So what we really have to do is make sure that, regardless the data, its content can never be interpreted as SQL. To do this, we use the escaping functions provided by the database API. We do this escaping in the database layer and not directly after receiving input as it may not be the only escaping (or filtering) we have to do. - https://www.drupal.org/node/101495

Just my 2 cents :)

  • 1
    This answer mixes up handling user input going into the database and user input being rendered. Two different things. – mpdonadio Jun 1 '16 at 15:14
  • well actually i want to check before any operation on data is performed. Just when we get the data from csv .if the csv contains any unsantize data the while loop should stop and an error msg should be displayed to user – namit garg Jun 3 '16 at 11:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.