diff --git a/src/net/sourceforge/plantuml/SourceStringReader.java b/src/net/sourceforge/plantuml/SourceStringReader.java index 9ed71af7a..32e7f5ace 100644 --- a/src/net/sourceforge/plantuml/SourceStringReader.java +++ b/src/net/sourceforge/plantuml/SourceStringReader.java @@ -154,7 +154,7 @@ public class SourceStringReader { public DiagramDescription outputImage(OutputStream os, int numImage, FileFormatOption fileFormatOption) throws IOException { if (blocks.size() == 0) { - noStartumlFound(os, fileFormatOption); + noValidStartFound(os, fileFormatOption); return null; } for (BlockUml b : blocks) { @@ -230,8 +230,8 @@ public class SourceStringReader { } - public ImageData noStartumlFound(OutputStream os, FileFormatOption fileFormatOption) throws IOException { - final TextBlock error = GraphicStrings.createForError(Arrays.asList("No @startuml/@enduml found"), + public ImageData noValidStartFound(OutputStream os, FileFormatOption fileFormatOption) throws IOException { + final TextBlock error = GraphicStrings.createForError(Arrays.asList("No valid @start/@end found, please check the version"), fileFormatOption.isUseRedForError()); return plainImageBuilder(error, fileFormatOption).write(os); diff --git a/src/net/sourceforge/plantuml/picoweb/PicoWebServer.java b/src/net/sourceforge/plantuml/picoweb/PicoWebServer.java index ca2bbb7bd..768d66fbd 100644 --- a/src/net/sourceforge/plantuml/picoweb/PicoWebServer.java +++ b/src/net/sourceforge/plantuml/picoweb/PicoWebServer.java @@ -269,9 +269,9 @@ public class PicoWebServer implements Runnable { if (ssr.getBlocks().size() == 0) { system = PSystemErrorUtils.buildV2(null, - new ErrorUml(SYNTAX_ERROR, "No @startuml/@enduml found", 0, new LineLocationImpl("", null)), null, + new ErrorUml(SYNTAX_ERROR, "No valid @start/@end found, please check the version", 0, new LineLocationImpl("", null)), null, Collections.emptyList()); - imageData = ssr.noStartumlFound(os, option.getFileFormatOption()); + imageData = ssr.noValidStartFound(os, option.getFileFormatOption()); } else { system = ssr.getBlocks().get(0).getDiagram(); imageData = system.exportDiagram(os, 0, option.getFileFormatOption()); diff --git a/test/net/sourceforge/plantuml/PipeTest.java b/test/net/sourceforge/plantuml/PipeTest.java index d88c0cca7..671928c78 100644 --- a/test/net/sourceforge/plantuml/PipeTest.java +++ b/test/net/sourceforge/plantuml/PipeTest.java @@ -217,12 +217,15 @@ class PipeTest { } @ParameterizedTest - @ValueSource(strings = { "ab\nc", // *nix, macOsX + @ValueSource(strings = { + "ab\nc", // *nix, macOsX "ab\rc", // pre-macOsX macs "ab\r\nc", // Windows // the case \n\r is handled as 2 new lines, thus not added - - "ab\nc\n", "ab\nc\r", "ab\nc\r\n" }) + "ab\nc\n", + "ab\nc\r", + "ab\nc\r\n" + }) void should_readFirstDiagram_decode_correctly_different_line_endings(String input) throws IOException { pipe = new Pipe(option, null, new ByteArrayInputStream(input.getBytes(UTF_8)), UTF_8.name()); @@ -247,6 +250,14 @@ class PipeTest { l.add(InputExpected.of("this-is-garbage\n@startuml\nab\rcde\n@enduml\nthis-is-garbage\n", "@startuml\nab\ncde\n@enduml\n")); l.add(InputExpected.of("@startwhatever\nab\rcde\n@endwhatever", "@startwhatever\nab\ncde\n@endwhatever\n")); + l.add(InputExpected.of("@start\nab\rcde\n@end", "@start\nab\ncde\n@end\n")); + // TODO: fix `readSingleDiagram` to allow @startX/@endX, the corresponding test is here: + // l.add(InputExpected.of("@startX\nab\rcde\n@endX", "@startX\nab\ncde\n@endX\n")); + l.add(InputExpected.of("@startXY\nab\rcde\n@endXY", "@startXY\nab\ncde\n@endXY\n")); + l.add(InputExpected.of("@startXYZ\nab\rcde\n@endXYZ", "@startXYZ\nab\ncde\n@endXYZ\n")); + l.add(InputExpected.of("@start1\nab\rcde\n@end1", "@start1\nab\ncde\n@end1\n")); + l.add(InputExpected.of("@start12\nab\rcde\n@end12", "@start12\nab\ncde\n@end12\n")); + l.add(InputExpected.of("@start123\nab\rcde\n@end123", "@start123\nab\ncde\n@end123\n")); return l; } @@ -274,6 +285,14 @@ class PipeTest { l.add(InputExpected.of("this-is-garbage\n@startuml\nab\rcde\n@enduml\nthis-is-garbage\n", "@startuml\nab\ncde\n@enduml\n")); l.add(InputExpected.of("@startwhatever\nab\rcde\n@endwhatever", "@startwhatever\nab\ncde\n@endwhatever\n")); + l.add(InputExpected.of("@start\nab\rcde\n@end", "@start\nab\ncde\n@end\n")); + // TODO: fix `readSingleDiagram` to allow @startX/@endX, the corresponding test is here: + // l.add(InputExpected.of("@startX\nab\rcde\n@endX", "@startX\nab\ncde\n@endX\n")); + l.add(InputExpected.of("@startXY\nab\rcde\n@endXY", "@startXY\nab\ncde\n@endXY\n")); + l.add(InputExpected.of("@startXYZ\nab\rcde\n@endXYZ", "@startXYZ\nab\ncde\n@endXYZ\n")); + l.add(InputExpected.of("@start1\nab\rcde\n@end1", "@start1\nab\ncde\n@end1\n")); + l.add(InputExpected.of("@start12\nab\rcde\n@end12", "@start12\nab\ncde\n@end12\n")); + l.add(InputExpected.of("@start123\nab\rcde\n@end123", "@start123\nab\ncde\n@end123\n")); return l; } diff --git a/test/net/sourceforge/plantuml/picoweb/PicoWebServerTest.java b/test/net/sourceforge/plantuml/picoweb/PicoWebServerTest.java index cdd9285c3..df2bce9cc 100644 --- a/test/net/sourceforge/plantuml/picoweb/PicoWebServerTest.java +++ b/test/net/sourceforge/plantuml/picoweb/PicoWebServerTest.java @@ -197,13 +197,13 @@ public class PicoWebServerTest { response = httpPostJson("/render", renderRequestJson("@startuml", "-ttxt")); assert response.getResponseCode() == 200; - assert response.getHeaderField("X-PlantUML-Diagram-Error").equals("No @startuml/@enduml found"); + assert response.getHeaderField("X-PlantUML-Diagram-Error").equals("No valid @start/@end found, please check the version"); assert response.getHeaderField("X-PlantUML-Diagram-Error-Line").equals("0"); assert response.getContentType().equals("text/plain"); assert readStreamAsString(response.getInputStream()).equals("" + " \n" + " \n" + - " No @startuml/@enduml found\n" + " No valid @start/@end found, please check the version\n" ); response = httpPostJson("/render", "");