Skip to content

Commit

Permalink
6.6.4 release
Browse files Browse the repository at this point in the history
Former-commit-id: d7765ba
  • Loading branch information
alderg committed May 24, 2017
1 parent 135e7ad commit a793f6c
Show file tree
Hide file tree
Showing 19 changed files with 954 additions and 388 deletions.
9 changes: 9 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
24-MAY-2017: 6.6.4

- Fixes possible data loss for back button
- Enables OneDrive support on iOS

22-MAY-2017: 6.6.3

- vsdx export improvements

19-MAY-2017: 6.6.2

- Adds trees plugin
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
6.6.2
6.6.4
52 changes: 33 additions & 19 deletions src/com/mxgraph/online/OpenServlet.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import org.apache.commons.fileupload.FileItemStream;
import org.apache.commons.fileupload.servlet.ServletFileUpload;
import org.apache.commons.fileupload.util.Streams;
import org.apache.commons.lang3.StringEscapeUtils;

import com.mxgraph.io.mxCodec;
import com.mxgraph.io.mxGraphMlCodec;
Expand Down Expand Up @@ -128,10 +129,10 @@ else if (name.equals("upfile"))
filename = item.getName();
vsdx = filename.toLowerCase().endsWith(".vsdx");
vssx = filename.toLowerCase().endsWith(".vssx");

if (vsdx || vssx)
{
upfile = Streams.asString(stream, "ISO-8859-1");
upfile = Streams.asString(stream, "ISO-8859-1");
}
else
{
Expand All @@ -152,11 +153,11 @@ else if (name.equals("upfile"))
}

String xml = null;

if (filename.toLowerCase().endsWith(".png"))
{
xml = extractXmlFromPng(upfile
.getBytes(Utils.CHARSET_FOR_URL_ENCODING));
xml = extractXmlFromPng(
upfile.getBytes(Utils.CHARSET_FOR_URL_ENCODING));
}
else if (ENABLE_GRAPHML_SUPPORT && upfile.matches(graphMlRegex))
{
Expand All @@ -165,12 +166,14 @@ else if (ENABLE_GRAPHML_SUPPORT && upfile.matches(graphMlRegex))
mxGraph graph = new mxGraphHeadless();

mxGraphMlCodec.decode(mxXmlUtils.parseXml(upfile), graph);
xml = mxXmlUtils.getXml(new mxCodec().encode(graph.getModel()));
xml = mxXmlUtils
.getXml(new mxCodec().encode(graph.getModel()));
}
else if (ENABLE_VSDX_SUPPORT && vsdx)
{
mxVsdxCodec vdxCodec = new mxVsdxCodec();
xml = vdxCodec.decodeVsdx(upfile.getBytes("ISO-8859-1"), Utils.CHARSET_FOR_URL_ENCODING);
xml = vdxCodec.decodeVsdx(upfile.getBytes("ISO-8859-1"),
Utils.CHARSET_FOR_URL_ENCODING);

// Replaces VSDX extension
int dot = filename.lastIndexOf('.');
Expand All @@ -179,7 +182,8 @@ else if (ENABLE_VSDX_SUPPORT && vsdx)
else if (ENABLE_VSSX_SUPPORT && vssx)
{
mxVssxCodec vssxCodec = new mxVssxCodec();
xml = vssxCodec.decodeVssx(upfile.getBytes("ISO-8859-1"), Utils.CHARSET_FOR_URL_ENCODING);
xml = vssxCodec.decodeVssx(upfile.getBytes("ISO-8859-1"),
Utils.CHARSET_FOR_URL_ENCODING);

// Replaces VSDX extension
int dot = filename.lastIndexOf('.');
Expand Down Expand Up @@ -210,10 +214,12 @@ else if (ENABLE_GLIFFY_SUPPORT && upfile.matches(gliffyRegex))
{
// Workaround for replacement char and null byte in IE9 request
xml = xml.replaceAll("[\\uFFFD\\u0000]*", "");
writeScript(writer, "try{window.parent.setCurrentXml(decodeURIComponent('"
+ Utils.encodeURIComponent(xml, Utils.CHARSET_FOR_URL_ENCODING)
+ "'), decodeURIComponent('" + Utils.encodeURIComponent(filename, Utils.CHARSET_FOR_URL_ENCODING)
+ "'));}catch(e){window.parent.showOpenAlert({message:window.parent.mxResources.get('notAUtf8File')});}");
writeScript(writer,
"try{window.parent.setCurrentXml(decodeURIComponent('"
+ encodeString(xml)
+ "'), decodeURIComponent('"
+ encodeString(filename)
+ "'));}catch(e){window.parent.showOpenAlert({message:window.parent.mxResources.get('notAUtf8File')});}");
}
}
else
Expand All @@ -223,25 +229,33 @@ else if (ENABLE_GLIFFY_SUPPORT && upfile.matches(gliffyRegex))
}
else
{
response.setStatus(HttpServletResponse.SC_REQUEST_ENTITY_TOO_LARGE);
writeScript(
writer,
response.setStatus(
HttpServletResponse.SC_REQUEST_ENTITY_TOO_LARGE);
writeScript(writer,
"window.parent.showOpenAlert(window.parent.mxResources.get('drawingTooLarge'));");
}
}
catch (Exception e)
{
e.printStackTrace();
response.setStatus(HttpServletResponse.SC_NOT_FOUND);
writeScript(
writer,
writeScript(writer,
"window.parent.showOpenAlert(window.parent.mxResources.get('invalidOrMissingFile'));");
}

writer.flush();
writer.close();
}

/**
* URI encodes the given string for JavaScript.
*/
protected String encodeString(String s)
{
return StringEscapeUtils.escapeEcmaScript(
Utils.encodeURIComponent(s, Utils.CHARSET_FOR_URL_ENCODING));
};

/**
* Writes the given string as a script in a HTML page to the given print writer.
*/
Expand All @@ -259,8 +273,8 @@ protected void writeScript(PrintWriter writer, String js)
// NOTE: Key length must not be longer than 79 bytes (not checked)
protected String extractXmlFromPng(byte[] data)
{
Map<String, String> textChunks = decodeCompressedText(new ByteArrayInputStream(
data));
Map<String, String> textChunks = decodeCompressedText(
new ByteArrayInputStream(data));

return (textChunks != null) ? textChunks.get("mxGraphModel") : null;
}
Expand Down
2 changes: 1 addition & 1 deletion war/cache.manifest
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
CACHE MANIFEST

# THIS FILE WAS GENERATED. DO NOT MODIFY!
# 05/19/2017 03:49 PM
# 05/24/2017 04:23 PM

app.html
index.html?offline=1
Expand Down
Loading

0 comments on commit a793f6c

Please sign in to comment.