In this paper, we present a detailed analysis of the effects of quadrupole components in radiofrequency (RF) photoinjectors, which could occur either in the RF cavity or in the gun solenoid, and their compensation using a skew quadrupole corrector. The analysis is generalized to the case in which the correction cannot be applied at the same location as the quadrupole. A practical guide to setting the corrector to eliminate correlation in the x-y space is discussed. Particle tracking simulations and measurements of emittance and beam matrix elements obtained at the UCLA Pegasus photoinjector are presented to validate the analysis.