mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Merge pull request #68 from overleaf/sk-fix-unicode-file-paths
Encode file path when building url, allows unicode
This commit is contained in:
commit
591617f996
1 changed files with 14 additions and 4 deletions
|
@ -5,10 +5,13 @@ import com.google.gson.JsonElement;
|
||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
import uk.ac.ic.wlgitbridge.data.filestore.RawFile;
|
import uk.ac.ic.wlgitbridge.data.filestore.RawFile;
|
||||||
import uk.ac.ic.wlgitbridge.data.filestore.RawDirectory;
|
import uk.ac.ic.wlgitbridge.data.filestore.RawDirectory;
|
||||||
|
import uk.ac.ic.wlgitbridge.util.Log;
|
||||||
import uk.ac.ic.wlgitbridge.util.Util;
|
import uk.ac.ic.wlgitbridge.util.Util;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.io.UnsupportedEncodingException;
|
||||||
|
import java.net.URLEncoder;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -115,10 +118,17 @@ public class CandidateSnapshot implements AutoCloseable {
|
||||||
JsonObject jsonFile = new JsonObject();
|
JsonObject jsonFile = new JsonObject();
|
||||||
jsonFile.addProperty("name", file.getPath());
|
jsonFile.addProperty("name", file.getPath());
|
||||||
if (file.isChanged()) {
|
if (file.isChanged()) {
|
||||||
jsonFile.addProperty(
|
String path = file.getPath();
|
||||||
"url",
|
String encodedPath;
|
||||||
projectURL + "/" + file.getPath() + "?key=" + postbackKey
|
try {
|
||||||
);
|
encodedPath = URLEncoder.encode(path, "UTF-8");
|
||||||
|
} catch (UnsupportedEncodingException e) {
|
||||||
|
// This should never happen
|
||||||
|
Log.error("Error while encoding file path: projectUrl={}, path={}", projectURL, path, e);
|
||||||
|
encodedPath = path;
|
||||||
|
}
|
||||||
|
String url = projectURL + "/" + encodedPath + "?key=" + postbackKey;
|
||||||
|
jsonFile.addProperty("url", url);
|
||||||
}
|
}
|
||||||
return jsonFile;
|
return jsonFile;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue