1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115
   |   MessageBytes undecodedURI = req.requestURI();  .................  MessageBytes decodedURI = req.decodedURI();          if (undecodedURI.getType() == 2) {             decodedURI.duplicate(undecodedURI);             this.parsePathParameters(req, request);
              try {                 req.getURLDecoder().convert(decodedURI.getByteChunk(), this.connector.getEncodedSolidusHandlingInternal());             } catch (IOException var22) {                 response.sendError(400, "Invalid URI: " + var22.getMessage());             }
              if (normalize(req.decodedURI())) {
 
 
   protected void parsePathParameters(Request req, org.apache.catalina.connector.Request request) { int semicolon = uriBC.indexOf(';', 0); for(; semicolon > -1; semicolon = uriBC.indexOf(';', semicolon)) {                 int start = uriBC.getStart();                 int end = uriBC.getEnd();                 int pathParamStart = semicolon + 1;                 int pathParamEnd = ByteChunk.findBytes(uriBC.getBuffer(), start + pathParamStart, end, new byte[]{59, 47});                 String pv = null;                 if (pathParamEnd < 0) {                     if (charset != null) {                         pv = new String(uriBC.getBuffer(), start + pathParamStart, end - start - pathParamStart, charset);                     }
                      uriBC.setEnd(start + semicolon); 
 
   public static boolean normalize(MessageBytes uriMB) {         ByteChunk uriBC = uriMB.getByteChunk();         byte[] b = uriBC.getBytes();         int start = uriBC.getStart();         int end = uriBC.getEnd();         if (start == end) {             return false;         } else {             int pos = false;             int index = false;             if (b[start] != 47 && b[start] != 92) {                 return false;             } else {                 int pos;                                  for(pos = start; pos < end; ++pos) {                     if (b[pos] == 92) {                         if (!ALLOW_BACKSLASH) {                             return false;                         }                         b[pos] = 47;                     } else if (b[pos] == 0) {                         return false;                     }                 }
                  for(pos = start; pos < end - 1; ++pos) {                     if (b[pos] == 47) {                         while(pos + 1 < end && b[pos + 1] == 47) {                             copyBytes(b, pos, pos + 1, end - pos - 1);                              --end;                         }                     }                 }
                  if (end - start >= 2 && b[end - 1] == 46 && (b[end - 2] == 47 || b[end - 2] == 46 && b[end - 3] == 47)) {                     b[end] = 47;                     ++end;                 }
                  uriBC.setEnd(end);                  int index = 0;
                  while(true) {                     index = uriBC.indexOf("/./", 0, 3, index);                     
                      if (index < 0) {                         index = 0;                                                  while(true) {                             index = uriBC.indexOf("/../", 0, 4, index);                                  return true;                             }
                              if (index == 0) {                                 return false;                             }
                              int index2 = -1;
                              for(pos = start + index - 1; pos >= 0 && index2 < 0; --pos) {                                 if (b[pos] == 47) {                                     index2 = pos;                                 }                             }
                              copyBytes(b, start + index2, start + index + 3, end - start - index - 3);                             end = end + index2 - index - 3;                             uriBC.setEnd(end);                             index = index2;                         }                     }                                          copyBytes(b, start + index, start + index + 2, end - start - index - 2);                     end -= 2;                     uriBC.setEnd(end);                 }             }         }     }                    
 
  |