Changeset 1377
- Timestamp:
- 2008-01-20 18:59:56 (9 months ago)
- Location:
- FCKeditor.Java/branches/2.4/src
- Files:
-
- 3 modified
-
main/java/net/fckeditor/connector/ConnectorServlet.java (modified) (2 diffs)
-
main/java/net/fckeditor/tool/Utils.java (modified) (3 diffs)
-
test/java/net/fckeditor/tool/UtilsTest.java (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
FCKeditor.Java/branches/2.4/src/main/java/net/fckeditor/connector/ConnectorServlet.java
r1361 r1377 114 114 String typeStr = request.getParameter("Type"); 115 115 String currentFolderStr = request.getParameter("CurrentFolder"); 116 116 boolean validPath = Utils.isValidPath(currentFolderStr); 117 117 // TODO untersuchen wie es vom Res Browser kommt 118 118 String currentPath = constructTypeBasedFolderString(typeStr, currentFolderStr); … … 121 121 File currentDir = new File(currentDirPath); 122 122 if (!currentDir.exists()) { 123 currentDir.mkdir ();123 currentDir.mkdirs(); 124 124 logger.debug("Dir successfull created: " + currentDirPath); 125 125 } -
FCKeditor.Java/branches/2.4/src/main/java/net/fckeditor/tool/Utils.java
r1375 r1377 24 24 import java.util.Set; 25 25 import java.util.StringTokenizer; 26 27 import org.apache.commons.io.FilenameUtils; 26 28 27 29 /** … … 119 121 120 122 // TODO code isn't very beautiful, is there a better way besides looping through the filename? 121 static String forceSingleExtension (final String filename) {123 public static String forceSingleExtension (final String filename) { 122 124 123 125 int lastDotPosition = filename.lastIndexOf("."); … … 129 131 } 130 132 131 static boolean isSingleExtension (final String filename) {133 public static boolean isSingleExtension (final String filename) { 132 134 133 135 return filename.matches("[^\\.]+\\.[^\\.]+"); 134 136 135 137 } 138 139 public static boolean isValidPath (final String path) { 140 141 if (isEmpty(path)) 142 return false; 143 144 if (!path.startsWith("/")) 145 return false; 146 147 if (isEmpty(FilenameUtils.normalize(path))) 148 return false; 149 150 return true; 151 } 136 152 } -
FCKeditor.Java/branches/2.4/src/test/java/net/fckeditor/tool/UtilsTest.java
r1375 r1377 146 146 assertEquals("hacked_.txt", actual); 147 147 } 148 149 @Test 150 public void isValidPath01 () { 151 String path = ""; 152 boolean condition = !Utils.isValidPath(path); 153 assertTrue(condition); 154 } 155 @Test 156 public void isValidPath02 () { 157 String path = "/"; 158 boolean condition = Utils.isValidPath(path); 159 assertTrue(condition); 160 } 161 162 @Test 163 public void isValidPath03 () { 164 String path = "/./"; 165 boolean condition = Utils.isValidPath(path); 166 assertTrue(condition); 167 } 168 169 @Test 170 public void isValidPath04 () { 171 String path = "/newf/.."; 172 boolean condition = Utils.isValidPath(path); 173 assertTrue(condition); 174 } 175 176 @Test 177 public void isValidPath05 () { 178 String path = "/../"; 179 boolean condition = !Utils.isValidPath(path); 180 assertTrue(condition); 181 } 182 183 @Test 184 public void isValidPath06 () { 185 String path = "/stuff/../.."; 186 boolean condition = !Utils.isValidPath(path); 187 assertTrue(condition); 188 } 189 190 @Test 191 public void isValidPath07 () { 192 String path = "/my/stuff/.."; 193 boolean condition = Utils.isValidPath(path); 194 assertTrue(condition); 195 } 148 196 }