code: protected File searchFile(String scriptName, String[] path)
      {
          if (scriptName == null || path == null)
          {
              return null;
          }
  
          for (String pathElement : path)
          {
              final File pathElementDir = new File(pathElement);
              // skip if pathElement is not a directory
              if (!pathElementDir.isDirectory())
              {
                  continue;
              }
  
              final File file = new File(pathElementDir, scriptName.replaceAll("/", Matcher.quoteReplacement(File.separator)));
              if (!file.exists())
              {
                  continue;
              }
  
              try
              {
                  // prevent attacks with scripts using ".." in their name.
                  if (!isInside(file, pathElementDir))
                  {
                      return null;
                  }
              }
              catch (IOException e)
              {
                  logger.warn("Unable to check whether '" + file.getPath() + "' is below '" + pathElementDir.getPath() + "'");
                  continue;
              }
  
              try
              {
                  return file.getCanonicalFile();
              }
              catch (IOException e)
              {
                  logger.error("Unable to get canonical file for '" + file.getPath() + "'", e);
              }
          }
          return null;
      }
docs: Searches for the file with the given name on the path.
  
  @param scriptName the name of the file to search for.
  @param path an array of directories to search for the file in order of
  preference.
  @return the canonical file if found on the path or <code>null</code> if
  not found.