mirror of
https://github.com/octoleo/plantuml-server.git
synced 2024-12-22 08:48:54 +00:00
[BUGFIX] Text/plain outputs always in unicode
This commit is contained in:
parent
7d7aa41168
commit
beb8c490b0
@ -44,7 +44,7 @@ public class AsciiServlet extends UmlDiagramService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public FileFormat getOutputFormat() {
|
public FileFormat getOutputFormat() {
|
||||||
return FileFormat.ATXT;
|
return FileFormat.UTXT;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -24,11 +24,11 @@
|
|||||||
package net.sourceforge.plantuml.servlet;
|
package net.sourceforge.plantuml.servlet;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.io.PrintWriter;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import javax.servlet.ServletOutputStream;
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
import net.sourceforge.plantuml.FileFormat;
|
import net.sourceforge.plantuml.FileFormat;
|
||||||
@ -49,7 +49,7 @@ class DiagramResponse {
|
|||||||
Map<FileFormat, String> map = new HashMap<FileFormat, String>();
|
Map<FileFormat, String> map = new HashMap<FileFormat, String>();
|
||||||
map.put(FileFormat.PNG, "image/png");
|
map.put(FileFormat.PNG, "image/png");
|
||||||
map.put(FileFormat.SVG, "image/svg+xml");
|
map.put(FileFormat.SVG, "image/svg+xml");
|
||||||
map.put(FileFormat.ATXT, "text/plain;charset=ISO-8859-1");
|
map.put(FileFormat.UTXT, "text/plain;charset=UTF-8");
|
||||||
contentType = Collections.unmodifiableMap(map);
|
contentType = Collections.unmodifiableMap(map);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -76,7 +76,7 @@ class DiagramResponse {
|
|||||||
SourceStringReader reader = new SourceStringReader(uml);
|
SourceStringReader reader = new SourceStringReader(uml);
|
||||||
String map = reader.generateImage(new NullOutputStream(), new FileFormatOption(FileFormat.PNG));
|
String map = reader.generateImage(new NullOutputStream(), new FileFormatOption(FileFormat.PNG));
|
||||||
String[] mapLines = map.split("[\\r\\n]");
|
String[] mapLines = map.split("[\\r\\n]");
|
||||||
ServletOutputStream httpOut = response.getOutputStream();
|
PrintWriter httpOut = response.getWriter();
|
||||||
for (int i=2; (i+1)<mapLines.length; i++) {
|
for (int i=2; (i+1)<mapLines.length; i++) {
|
||||||
httpOut.print(mapLines[i]);
|
httpOut.print(mapLines[i]);
|
||||||
}
|
}
|
||||||
|
@ -68,7 +68,7 @@ public class MapServlet extends HttpServlet {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public FileFormat getOutputFormat() {
|
public FileFormat getOutputFormat() {
|
||||||
return FileFormat.ATXT;
|
return FileFormat.UTXT;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -14,6 +14,7 @@ public class AllTests extends TestSuite {
|
|||||||
suite.addTestSuite(TestSVG.class);
|
suite.addTestSuite(TestSVG.class);
|
||||||
suite.addTestSuite(TestProxy.class);
|
suite.addTestSuite(TestProxy.class);
|
||||||
suite.addTestSuite(TestMap.class);
|
suite.addTestSuite(TestMap.class);
|
||||||
|
suite.addTestSuite(TestCharset.class);
|
||||||
// $JUnit-END$
|
// $JUnit-END$
|
||||||
return suite;
|
return suite;
|
||||||
}
|
}
|
||||||
|
@ -17,6 +17,7 @@ public class TestAsciiArt extends WebappTestCase {
|
|||||||
// Analyze response
|
// Analyze response
|
||||||
// Verifies the Content-Type header
|
// Verifies the Content-Type header
|
||||||
assertEquals("Response content type is not TEXT PLAIN", "text/plain", response.getContentType());
|
assertEquals("Response content type is not TEXT PLAIN", "text/plain", response.getContentType());
|
||||||
|
assertEquals("Response character set is not UTF-8", "UTF-8", response.getCharacterSet());
|
||||||
// Get the content and verify its size
|
// Get the content and verify its size
|
||||||
String diagram = response.getText();
|
String diagram = response.getText();
|
||||||
int diagramLen = diagram.length();
|
int diagramLen = diagram.length();
|
||||||
|
@ -19,7 +19,7 @@ public class TestMap extends WebappTestCase {
|
|||||||
// Analyze response
|
// Analyze response
|
||||||
// Verifies the Content-Type header
|
// Verifies the Content-Type header
|
||||||
assertEquals("Response content type is not TEXT PLAIN", "text/plain", response.getContentType());
|
assertEquals("Response content type is not TEXT PLAIN", "text/plain", response.getContentType());
|
||||||
assertEquals("Response character set is not ISO-8859-1", "ISO-8859-1", response.getCharacterSet());
|
assertEquals("Response character set is not UTF-8", "UTF-8", response.getCharacterSet());
|
||||||
// Get the content, check its first characters and verify its size
|
// Get the content, check its first characters and verify its size
|
||||||
String diagram = response.getText();
|
String diagram = response.getText();
|
||||||
assertTrue("Response content is not starting with <area", diagram.startsWith("<area"));
|
assertTrue("Response content is not starting with <area", diagram.startsWith("<area"));
|
||||||
|
Loading…
Reference in New Issue
Block a user