|
Lines 114-124
class FileHandlerV1 extends GenericFileHandler {
Link Here
|
| 114 |
private void handlePatchContents(HttpServletRequest request, BufferedReader requestReader, HttpServletResponse response, IFileStore file) throws IOException, CoreException, NoSuchAlgorithmException, JSONException, ServletException { |
114 |
private void handlePatchContents(HttpServletRequest request, BufferedReader requestReader, HttpServletResponse response, IFileStore file) throws IOException, CoreException, NoSuchAlgorithmException, JSONException, ServletException { |
| 115 |
JSONObject changes = OrionServlet.readJSONRequest(request); |
115 |
JSONObject changes = OrionServlet.readJSONRequest(request); |
| 116 |
//read file to memory |
116 |
//read file to memory |
| 117 |
Reader fileReader = new InputStreamReader(file.openInputStream(EFS.NONE, null)); |
117 |
Reader fileReader = new InputStreamReader(file.openInputStream(EFS.NONE, null), "UTF-8"); |
| 118 |
StringWriter oldFile = new StringWriter(); |
118 |
StringWriter oldFile = new StringWriter(); |
| 119 |
IOUtilities.pipe(fileReader, oldFile, true, false); |
119 |
IOUtilities.pipe(fileReader, oldFile, true, false); |
| 120 |
StringBuffer oldContents = oldFile.getBuffer(); |
120 |
StringBuffer oldContents = oldFile.getBuffer(); |
| 121 |
|
121 |
|
|
|
122 |
// Remove the BOM character if it exists |
| 123 |
if (oldContents.length() > 0) { |
| 124 |
char firstChar = oldContents.charAt(0); |
| 125 |
if (firstChar == '\uFEFF' || firstChar == '\uFFFE') { |
| 126 |
oldContents.replace(0, 1, ""); |
| 127 |
} |
| 128 |
} |
| 129 |
|
| 122 |
JSONArray changeList = changes.getJSONArray("diff"); |
130 |
JSONArray changeList = changes.getJSONArray("diff"); |
| 123 |
for (int i = 0; i < changeList.length(); i++) { |
131 |
for (int i = 0; i < changeList.length(); i++) { |
| 124 |
JSONObject change = changeList.getJSONObject(i); |
132 |
JSONObject change = changeList.getJSONObject(i); |