mirror of
https://github.com/octoleo/plantuml.git
synced 2024-11-05 21:17:52 +00:00
mod: Handle @start/@end syntax error better
https://github.com/plantuml/plantuml/pull/1522
This commit is contained in:
parent
9b761b7f92
commit
4b58055b9f
@ -47,13 +47,14 @@ import java.io.PrintStream;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import net.sourceforge.plantuml.core.Diagram;
|
||||
import net.sourceforge.plantuml.core.DiagramDescription;
|
||||
import net.sourceforge.plantuml.error.PSystemError;
|
||||
import net.sourceforge.plantuml.preproc.Defines;
|
||||
import net.sourceforge.plantuml.security.SFile;
|
||||
import net.sourceforge.plantuml.url.CMapData;
|
||||
|
||||
public class Pipe {
|
||||
// ::remove file when __CORE__
|
||||
@ -190,7 +191,12 @@ public class Pipe {
|
||||
if (state == State.START_MARK_NOT_FOUND && line.startsWith("@start")) {
|
||||
sb.setLength(0); // discard any previous input
|
||||
state = State.START_MARK_FOUND;
|
||||
expectedEnd = "@end" + line.substring(6).split("^[A-Za-z]")[0];
|
||||
final Matcher m = Pattern.compile("@start([A-Za-z]*)").matcher(line);
|
||||
if (m.matches())
|
||||
expectedEnd = "@end" + m.group(1);
|
||||
else
|
||||
expectedEnd = "@end";
|
||||
|
||||
} else if (state == State.START_MARK_FOUND && line.startsWith(expectedEnd)) {
|
||||
state = State.COMPLETE;
|
||||
}
|
||||
|
@ -251,8 +251,7 @@ class PipeTest {
|
||||
"@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("@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"));
|
||||
@ -286,8 +285,8 @@ class PipeTest {
|
||||
"@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("@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"));
|
||||
|
Loading…
Reference in New Issue
Block a user