private static boolean looksUnsafeForFastParser ( String s ) { boolean lastWasDot = true ; // start of path is also a "dot" int len = s . length ( ) ; if ( s . isEmpty ( ) ) return true ; if ( s . charAt ( 0 ) == ' ' ) return true ; if ( s . charAt ( len - 1 ) == ' ' ) return true ; for ( int i = 0 ; i < len ; ++ i ) { char c = s . charAt ( i ) ; if ( ( c >= ' ' && c <= ' ' ) || ( c >= ' ' && c <= ' ' ) || c == ' ' ) { lastWasDot = false ; continue ; } else if ( c == ' ' ) { if ( lastWasDot ) return true ; // ".." means we need to throw an error lastWasDot = true ; } else if ( c == ' ' ) { if ( lastWasDot ) return true ; continue ; } else { return true ; } } if ( lastWasDot ) return true ; return false ; }
that might require the full parser to deal with .