Replacing a safety capacitor
Looking at what little bit of the PCB you have in the picture this looks to be a part of a simple budget power supply like this:







simulate this circuit &ndash; Schematic created using CircuitLab

That's a very popular way of making a dirt cheap PSU for something which needs little current, or to bootstrap a larger SMPS. The safety caps often fail and then the whole device appears dead.

If that's the case the exact value of the capacitor isn't likely to be that critical, nor the length of the leads (you're dealing with low frequencies, and there's already plenty of resistance in series). Although, depending on how you extend them (bending them flat against the board at one end is popular), you'll want to be careful of making it easier to touch the live side.

You can also get axial X2 caps which might make it easier to fit your board, and you can always consider drilling a hole in the PCB for the lead if you don't compromise an insulation gap and the geometry of the tracks fits. But I'm surprised you can't find an exact fit - you don't give the lead pitch otherwise I'd find one.

-- edit --

your original capacitor's data is here

http://www.dain.com.tw/productd412.html?mod=show&amp;cid=2&amp;pid=MPX%28275VAC%29&amp;lg=E

They give L=26.5, H=19, D=10 and pitch 22.5, given you referenced CPC I'm guessing you're in the UK, so an appropriate replacement would be RS  869-7431

which has L=25.5 D=10.5, H=19.5 and a pitch of 22.5 with a MOQ of 5.

https://uk.rs-online.com/web/p/polyester-film-capacitors/8697431/