According to rule 5.09(a):
"A catch is the act of a fielder in getting secure possession in his hand or glove of a ball in flight and firmly holding it in his possession; providing he does not use his cap, protector, pocket or any part of his uniform in getting possesion."
It doesn't say he gets a single, but it is not an out.
A related rule:
"When a pitched ball becomes stuck in a catcher’s mask or gear, it is an immediate dead ball. According to MLB Rule 5.06(c)(7), runners are awarded one base, and the batter is awarded first base if it was ball four or strike three. It is not considered a catch if the ball lodges in the mask on a foul tip."
The catcher is not the pitcher, but seems to be very similar to what happened with Gilbert.