@@ -888,16 +888,14 @@ private String instantiate(Map<String, String> values, boolean allowPartial) {
888888 || nextNext .kind () != SegmentKind .END_BINDING ;
889889 restore (iterator , iterator .nextIndex () - 2 );
890890 if (!pathEscape ) {
891- validatePathSegment (var , value , value , false );
891+ validatePathSegment (var , value );
892892 result .append (encodeUrl (value ));
893893 } else {
894- boolean hasPathWildcard =
895- next .kind () == SegmentKind .PATH_WILDCARD || hasPathWildcard (iterator );
896894 // For a path wildcard or path of length greater 1, split the value and escape
897895 // every sub-segment.
898896 boolean first = true ;
899897 for (String subSeg : SLASH_SPLITTER .split (value )) {
900- validatePathSegment (var , value , subSeg , hasPathWildcard );
898+ validatePathSegment (var , subSeg );
901899 if (!first ) {
902900 result .append ('/' );
903901 }
@@ -1214,31 +1212,10 @@ private static List<Segment> parseComplexResourceId(String seg) {
12141212
12151213 private static final PercentEscaper URL_ESCAPER = new PercentEscaper ("-_.~" , false );
12161214
1217- private static boolean hasPathWildcard (ListIterator <Segment > iterator ) {
1218- int start = iterator .nextIndex ();
1219- boolean found = false ;
1220- while (iterator .hasNext ()) {
1221- Segment seg = iterator .next ();
1222- if (seg .kind () == SegmentKind .END_BINDING ) {
1223- break ;
1224- }
1225- if (seg .kind () == SegmentKind .PATH_WILDCARD ) {
1226- found = true ;
1227- break ;
1228- }
1229- }
1230- restore (iterator , start );
1231- return found ;
1232- }
1233-
1234- private static void validatePathSegment (
1235- String var , String fullValue , String segment , boolean hasPathWildcard ) {
1215+ private static void validatePathSegment (String var , String segment ) {
12361216 if ("." .equals (segment ) || ".." .equals (segment )) {
1237- if (hasPathWildcard ) {
1238- throw new ValidationException (
1239- "Value for %s must not contain segments that are exactly . or .." , var );
1240- }
1241- throw new ValidationException ("Invalid value %s for %s." , fullValue , var );
1217+ throw new ValidationException (
1218+ "Value for %s must not contain segments that are exactly . or .." , var );
12421219 }
12431220 }
12441221
0 commit comments