The relevant words form Rule 6-15:
... If the puck was last touched by a defending player before it entered
the cage, the goal is allowed regardless of the manner in which the puck
was caused to enter the cage, except that if an attacking player propels
the puck other than with his stick, or illegally with his stick and it
bounds or deflects off the person or equipment to the goalkeeper or any
other defensive player, the goal shall not be allowed.
... If the puck is deflected into the goal from the shot of an attacking
player by striking any part of the person of a player of the same side,
the goal shall be allowed.