All pastes #902116 Raw Edit

Miscellany

public text v1 · immutable
·published 2008-02-13 04:39 UTC
rendered paste body
    $value =~ s/&(amp|quot)(?!;)/&$1;/g;        # fix &amp and &quot without semi-colon                                 
    $value =~ s/&(nbsp)(?!;)/ /g;          # fix &nbsp without trailing semi-colon                                 
    $value =~ s/&(#\d+)(?!;)/&$1;/g;            # fix &#<entity> without trailing semi-colon                            
    $value =~ s/&(?!(amp|#\d+;|quot))/&amp;/g;  # convert any ampersands that are not an entity to &amp;                
    $value =~ s/</&lt;/g;                       # convert tags. TODO: the doc decl should allow html...                 
    $value =~ s/>/&gt;/g;                                                                                               
                                                                                                                        
    # sanitze binary chars                                                                                              
    $value =~ tr/\x91\x92\x93\x94\x96\x97/''""\-\-/;                                                                    
    $value =~ s/\x85/.../sg;                                                                                            
    $value =~ tr/\x80-\x9F//d;