How to add safety to line voltage connected to D-SUB?
I'd not put mains on a DSUB-xx (and I've been putting mains on things for 50+ years :-) ).

EXCEPT,  back of brain says that you can (or may be able to) get ones with mains rated shrouded contacts - these (if they exist) are super rare and no standard. 

For a prototype, unless you need the "all connect together aspects" of a single connector, I'd use two connectors, or some other connector. It's doable, but "hairy". 

The safest way of ensuring mains does not get out of control people-wise is to use an earth leak circuit breaker (ELCB) / ground fault interrupter (GFI).
That saves lives but NOT equipment -  a person will feel a shock* but the mains will be interrupted fast enough to (almost always) not be killed. (*Ask me how I know :-) ).
BUT equipment will usually be damaged.

A fuse will also open the circuit - but will not usually save lives or equipment downstream of the fault.  

A polyfuse protected circuit will limit current, but still kill you.

GFI/ELCB for life protection and maybe a tranzorb for energy absorption MAY prevent damage. 



A large range of subminiature connectors with various add in contacts - usually aimed at high current or coaxial here

Not what you want, but shows what people do ...



And ...

(I have no involvement whatsoever with "Signal Origin" - they just seemed to have parts worth using as examples.)