If somebody attacks me in an interior from behind, I don't see why I can't use pepper spray to defend myself.
If we apply the logic of through walls, then chainsaws should also be disabled since you can use them through walls and get people bugged.
The chainsaw has shorter range, meaning you have a chance to at least get to the door of the room and see the user, also chainsaw has an additional cool-down usage so if you get caught by it from behind a wall, you got a chance to get out of its grip and you can move freely. So it’s tolerable.
The spray cane and especially the fire extinguisher have longer range and no cool-down (just hold right click from behind the wall and the hallways will be blocked by its chemicals), you start coughing before you see the attacker behind the room wall because you never reach the door.