Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ public static void main(String[] args) {
return;
}

VariableDeclarator expectedPatternDecl = null;
VariableDeclarator serverDecl = null;
VariableDeclarator uriReferenceDecl = null;
ReturnStmt expectedReturnStmt = null;

for (Statement statement : constructMethod.getBody().get().getStatements()) {
Expand All @@ -96,7 +97,10 @@ public static void main(String[] args) {

if (expression.toString().equals(
"String uriReference = \"^(\" + absoluteuri + \"|\" + relativeuri + \")?(#\" + fragment + \")?$\"")) {
expectedPatternDecl = varDeclExpr.getVariable(0);
uriReferenceDecl = varDeclExpr.getVariable(0);
} else if (expression.toString().equals(
"String server = \"((\" + userinfo + \"@)?\" + hostport + \")?\"")) {
serverDecl = varDeclExpr.getVariable(0);
}
}
} else if (statement.isReturnStmt()) {
Expand All @@ -108,7 +112,18 @@ public static void main(String[] args) {
}
}

if (expectedPatternDecl == null) {
if (serverDecl == null) {
System.err.println(
"The constructMatchesRfc2396 lacks the "
+ "String server = \"((\" + userinfo + \"@)?\" + hostport + \")?\""
+ "statement in "
+ sourcePath
);
System.exit(1);
return;
}

if (uriReferenceDecl == null) {
System.err.println(
"The constructMatchesRfc2396 lacks the "
+ "'String uriReference = \"^(\" + absoluteuri + \"|\" + relativeuri + \")?(#\" + fragment + \")?$\"' "
Expand All @@ -128,8 +143,13 @@ public static void main(String[] args) {
return;
}

expectedPatternDecl.setInitializer(
"\"(\" + absoluteuri + \"|\" + relativeuri + \")?(#\" + fragment + \")?\""
// NOTE (empwilli): we take care to also escape # and @ characters; these
// carry special meaning in Automaton.
serverDecl.setInitializer(
"\"((\" + userinfo + \"\\\\@)?\" + hostport + \")?\""
);
uriReferenceDecl.setInitializer(
"\"(\" + absoluteuri + \"|\" + relativeuri + \")?(\\\\#\" + fragment + \")?\""
);

expectedReturnStmt.setExpression(
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/aas_core/aas3_0/verification/Verification.java
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ private static Automaton constructMatchesRfc2396() {
String host = "(" + hostname + "|" + ipv4address + ")";
String port = "[0-9]*";
String hostport = host + "(:" + port + ")?";
String server = "((" + userinfo + "@)?" + hostport + ")?";
String server = "((" + userinfo + "\\@)?" + hostport + ")?";
String regName = "(" + unreserved + "|" + escaped + "|[$,;:@&=+])+";
String authority = "(" + server + "|" + regName + ")";
String netPath = "//" + authority + "(" + absPath + ")?";
Expand All @@ -196,7 +196,7 @@ private static Automaton constructMatchesRfc2396() {
String relSegment = "(" + unreserved + "|" + escaped + "|[;@&=+$,])+";
String relPath = relSegment + "(" + absPath + ")?";
String relativeuri = "(" + netPath + "|" + absPath + "|" + relPath + ")(\\?" + query + ")?";
String uriReference = "(" + absoluteuri + "|" + relativeuri + ")?(#" + fragment + ")?";
String uriReference = "(" + absoluteuri + "|" + relativeuri + ")?(\\#" + fragment + ")?";
return new RegExp(uriReference).toAutomaton();
}

Expand Down
Loading