cyphersec A blog about Web Application Security and .NET development best practices

16Mar/090

Hardcore code validation

private bool IsCleaned(string untrustedText)
{
      System.Text.ASCIIEncoding encoding =new System.Text.ASCIIEncoding();
    bool iscleaned = false;
    foreach (byte chunk in encoding.GetBytes(untrustedText)) {
        // 60 = < | 62 = > |45 = - | 39 = '
        if ((chunk == 60) || (chunk == 62) || (chunk == 45) || (chunk == 39)) {
            iscleaned = false;
            break;
        }
        else  { iscleaned = true; }
    }
    return iscleaned;      
}

About Alessio Marziali

Alessio Marziali (MCTS) is a Security Consultant with 9 years of experience developing secure applications with Microsoft .NET in a variety of sectors in UK and Italy. Published technical author with two ASP.NET books currently available for purchase and OWASP Code Crawler Project Leader.
Comments (0) Trackbacks (0)

No comments yet.


Leave a comment


CAPTCHA image

No trackbacks yet.