dsmiley commented on a change in pull request #1600:
URL: https://github.com/apache/lucene-solr/pull/1600#discussion_r444641471



##########
File path: solr/core/src/java/org/apache/solr/handler/CatStream.java
##########
@@ -158,28 +157,20 @@ public Explanation toExplanation(StreamFactory factory) 
throws IOException {
   }
 
   private List<CrawlFile> validateAndSetFilepathsInSandbox() {
-    final String[] relativePathRoots = commaDelimitedFilepaths.split(",");
-
     final List<CrawlFile> crawlSeeds = new ArrayList<>();
-    for (String crawlRoot : relativePathRoots) {
-      final File crawlRootFile = new File(crawlRoot);
-      if (crawlRootFile.isAbsolute()) {
-        throw new SolrException(SolrException.ErrorCode.BAD_REQUEST,
-            "file/directory to stream must be provided as an absolute path: " 
+ crawlRoot);
-      }
-      if ( crawlRoot.contains("..")) {
+    for (String crawlRootStr : commaDelimitedFilepaths.split(",")) {
+      Path crawlRootPath = chroot.resolve(crawlRootStr).normalize();
+      if (! crawlRootPath.startsWith(chroot)) {

Review comment:
       Path "startsWith" API makes what you were trying to do simpler (less 
code).

##########
File path: solr/core/src/java/org/apache/solr/core/SolrPaths.java
##########
@@ -94,26 +87,6 @@ public static Path locateSolrHome() {
     return Paths.get(home).toAbsolutePath().normalize();
   }
 
-  public static void ensureUserFilesDataDir(Path solrHome) {
-    final Path userFilesPath = getUserFilesPath(solrHome);
-    final File userFilesDirectory = new File(userFilesPath.toString());
-    if (!userFilesDirectory.exists()) {

Review comment:
       The delta here with Paths API isn't line-for-line; it's much better.  
`Files.createDirectories` works if it exists and simply throws if something 
goes wrong.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to