Legal? What do you mean by that?
Studies have been done on this, with food being dropped on the floor then cultured to grow the bacteria, and generally the result is that you are at no greater risk from picking food off the floor and eating it than from non-dropped food.Personally, if I have to pick dog hairs and grit off it, I probably wouldn't bother, unless of course it was the last piece of rich fruit cake or Bara Brith, when all bets are off.
Oh, and most people know it as the 5 second rule.