public boolean failsChecks ( String text , CheckResult checkResult ) { int length = text . length ( ) ; int result = 0 ; if ( checkResult != null ) { checkResult . position = 0 ; checkResult . numerics = null ; checkResult . restrictionLevel = null ; } if ( 0 != ( this . fChecks & RESTRICTION_LEVEL ) ) { RestrictionLevel textRestrictionLevel = getRestrictionLevel ( text ) ; if ( textRestrictionLevel . compareTo ( fRestrictionLevel ) > 0 ) { result |= RESTRICTION_LEVEL ; } if ( checkResult != null ) { checkResult . restrictionLevel = textRestrictionLevel ; } } if ( 0 != ( this . fChecks & MIXED_NUMBERS ) ) { UnicodeSet numerics = new UnicodeSet ( ) ; getNumerics ( text , numerics ) ; if ( numerics . size ( ) > 1 ) { result |= MIXED_NUMBERS ; } if ( checkResult != null ) { checkResult . numerics = numerics ; } } if ( 0 != ( this . fChecks & CHAR_LIMIT ) ) { int i ; int c ; for ( i = 0 ; i < length ; ) { // U16_NEXT(text, i, length, c); c = Character . codePointAt ( text , i ) ; i = Character . offsetByCodePoints ( text , i , 1 ) ; if ( ! this . fAllowedCharsSet . contains ( c ) ) { result |= CHAR_LIMIT ; break ; } } } if ( 0 != ( this . fChecks & INVISIBLE ) ) { // This check needs to be done on NFD input String nfdText = nfdNormalizer . normalize ( text ) ; // scan for more than one occurrence of the same non-spacing mark // in a sequence of non-spacing marks. int i ; int c ; int firstNonspacingMark = 0 ; boolean haveMultipleMarks = false ; UnicodeSet marksSeenSoFar = new UnicodeSet ( ) ; // Set of combining marks in a // single combining sequence. for ( i = 0 ; i < length ; ) { c = Character . codePointAt ( nfdText , i ) ; i = Character . offsetByCodePoints ( nfdText , i , 1 ) ; if ( Character . getType ( c ) != UCharacterCategory . NON_SPACING_MARK ) { firstNonspacingMark = 0 ; if ( haveMultipleMarks ) { marksSeenSoFar . clear ( ) ; haveMultipleMarks = false ; } continue ; } if ( firstNonspacingMark == 0 ) { firstNonspacingMark = c ; continue ; } if ( ! haveMultipleMarks ) { marksSeenSoFar . add ( firstNonspacingMark ) ; haveMultipleMarks = true ; } if ( marksSeenSoFar . contains ( c ) ) { // report the error, and stop scanning. // No need to find more than the first failure. result |= INVISIBLE ; break ; } marksSeenSoFar . add ( c ) ; } } if ( checkResult != null ) { checkResult . checks = result ; } return ( 0 != result ) ; }
Check the specified string for possible security issues . The text to be checked will typically be an identifier of some sort . The set of checks to be performed was specified when building the SpoofChecker .