File tree Expand file tree Collapse file tree 2 files changed +4
-11
lines changed
main/java/com/google/common/labs/parse
test/java/com/google/common/labs/parse Expand file tree Collapse file tree 2 files changed +4
-11
lines changed Original file line number Diff line number Diff line change @@ -160,15 +160,14 @@ public static Parser<String> string(String value) {
160160 * @since 9.4
161161 */
162162 public static Parser <String > quotedStringWithEscapes (
163- char quoteChar , Function <? super Character , String > unescapeFunction ) {
163+ char quoteChar , Function <? super Character , ? extends CharSequence > unescapeFunction ) {
164164 requireNonNull (unescapeFunction );
165- CharPredicate allowedChars = c -> !Character .isISOControl (c );
166165 checkArgument (quoteChar != '\\' , "quoteChar cannot be '\\ '" );
167- checkArgument (allowedChars . test (quoteChar ), "quoteChar cannot be %s" , quoteChar );
166+ checkArgument (! Character . isISOControl (quoteChar ), "quoteChar cannot be a control character" );
168167 String quoteString = Character .toString (quoteChar );
169168 return anyOf (
170- consecutive (isNot (quoteChar ).and (isNot ('\\' )). and ( allowedChars ) , "quoted chars" ),
171- string ("\\ " ).then (single (allowedChars , "escaped char" ).map (unescapeFunction )))
169+ consecutive (isNot (quoteChar ).and (isNot ('\\' )), "quoted chars" ),
170+ string ("\\ " ).then (single (CharPredicate . ANY , "escaped char" ).map (unescapeFunction )))
172171 .zeroOrMore (joining ())
173172 .immediatelyBetween (quoteString , quoteString );
174173 }
Original file line number Diff line number Diff line change @@ -2329,12 +2329,6 @@ public void quotedStringWithEscapes_failures() {
23292329 assertThrows (ParseException .class , () -> singleQuoted .parse ("'foo" )); // unclosed
23302330 assertThrows (ParseException .class , () -> singleQuoted .parse ("'foo'bar" )); // leftover
23312331 assertThrows (ParseException .class , () -> singleQuoted .parse ("'foo\\ " )); // dangling escape
2332- assertThrows (ParseException .class , () -> singleQuoted .parse ("foo\n " )); // literal newline
2333- assertThrows (ParseException .class , () -> singleQuoted .parse ("foo\r " )); // CR
2334- assertThrows (ParseException .class , () -> singleQuoted .parse ("foo\t " ));
2335- assertThrows (ParseException .class , () -> singleQuoted .parse ("\\ \n " )); // literal newline
2336- assertThrows (ParseException .class , () -> singleQuoted .parse ("\\ \r " )); // CR
2337- assertThrows (ParseException .class , () -> singleQuoted .parse ("\\ \t " ));
23382332 }
23392333
23402334 @ Test
You can’t perform that action at this time.
0 commit comments