Skip to content

Commit

Permalink
Encoding / decoding request parameter (#27)
Browse files Browse the repository at this point in the history
  • Loading branch information
mohamed-ennahdi authored Dec 23, 2024
1 parent b91bb59 commit c5e14ee
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import java.io.IOException;
import java.io.Writer;
import java.net.URISyntaxException;
import java.net.URLDecoder;
import java.nio.charset.Charset;
import java.nio.file.Files;
import java.util.ArrayList;
import java.util.List;
Expand All @@ -31,9 +33,10 @@ public String generateHTML(String[] sourceCodes) throws IOException, URISyntaxEx
try {
String patternString = "(?<=class ).*?(?=\\s)";
Pattern pattern = Pattern.compile(patternString);
String path = System.getProperty("user.home");
for (String sourceCode: sourceCodes) {
sourceCode = URLDecoder.decode(sourceCodes[0], Charset.forName("UTF-8"));
Matcher matcher = pattern.matcher(sourceCode);
if (matcher.find()) {
String fileName = matcher.group() + ".java";
Expand Down
2 changes: 1 addition & 1 deletion objectmorph-app/src/main/resources/public/client.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ <h4>
function dropfile(file) {
var reader = new FileReader();
reader.onload = function(e) {
files.push(e.target.result);
files.push(encodeURIComponent(e.target.result));
};
reader.readAsText(file, "UTF-8");
}
Expand Down
2 changes: 1 addition & 1 deletion objectmorph-logic/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<dependency>
<groupId>com.github.javaparser</groupId>
<artifactId>javaparser-core</artifactId>
<version>3.26.1</version>
<version>3.26.3</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.projectlombok/lombok -->
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public JavaClassInterpreter(File myClassSourceFile) {

if( ocu.isPresent() ) {
CompilationUnit cu = ocu.get();
this.className = cu.getPrimaryTypeName().get();
this.className = cu.getTypes().get(0).getNameAsString();
this.packageName = cu.getPackageDeclaration().isPresent() ? cu.getPackageDeclaration().get().getName().asString() : "";
this.decl = cu.getClassByName(this.className).get();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,12 @@ public String generateFullHTML() throws FileNotFoundException, URISyntaxExceptio
}
fixeLineScript += " } ";

relations.get(0).resetInstanceId();
interpreters.get(0).resetInstanceId();
if (!relations.isEmpty()) {
relations.get(0).resetInstanceId();
}
if (!interpreters.isEmpty()) {
interpreters.get(0).resetInstanceId();
}

return html(
head(
Expand Down

0 comments on commit c5e14ee

Please sign in to comment.