Skip to content
Snippets Groups Projects
Unverified Commit b981e429 authored by Grégory Mantelet's avatar Grégory Mantelet Committed by GitHub
Browse files

[UWS,TAP] Merge pull request #88 from marcdexet-cnrs/master

Quote file separator to avoid backslash failures in reg-exp (especially on a Windows-OS)
parents e6e8fd69 0384ef2a
No related branches found
No related tags found
No related merge requests found
......@@ -44,7 +44,7 @@ public class DefaultOwnerGroupIdentifier implements OwnerGroupIdentifier {
return null;
else{
// The user directory name = userID in which each directory separator char are replaced by a _ (=> no confusion with a path):
String userDir = owner.getID().trim().replaceAll(File.separator, "_");
String userDir = owner.getID().trim().replaceAll(Pattern.quote(File.separator), "_");
// The parent directory = the first LETTER of the userID or _ if none can be found:
String parentDir = "_";
......
......@@ -40,6 +40,7 @@ import java.util.Date;
import java.util.Iterator;
import java.util.List;
import java.util.NoSuchElementException;
import java.util.regex.Pattern;
import uws.UWSException;
import uws.UWSToolBox;
......@@ -214,7 +215,7 @@ public class LocalUWSFileManager implements UWSFileManager {
if (ownerGroup != null)
ownerDir = new File(rootDirectory, ownerGroup);
}
ownerDir = new File(ownerDir, owner.getID().replaceAll(File.separator, "_"));
ownerDir = new File(ownerDir, owner.getID().replaceAll(Pattern.quote(File.separator), "_"));
return ownerDir;
}
......@@ -713,7 +714,7 @@ public class LocalUWSFileManager implements UWSFileManager {
protected String getBackupFileName(final JobOwner owner) throws IllegalArgumentException{
if (owner == null || owner.getID() == null || owner.getID().trim().isEmpty())
throw new IllegalArgumentException("Missing owner! Can not get the backup file of an unknown owner.");
return owner.getID().replaceAll(File.separator, "_") + ".backup";
return owner.getID().replaceAll(Pattern.quote(File.separator), "_") + ".backup";
}
@Override
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment