Skip to content

Commit

Permalink
Bugfix: Fix json escaping (#74)
Browse files Browse the repository at this point in the history
  • Loading branch information
MDK5 authored Nov 19, 2021
1 parent fbf2693 commit 9b916d3
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ class ArtemisClientConnector(private val project: Project) : JavaScriptConnector
}

private fun executeJSFunction(function: JavaScriptFunction, vararg args: Any) {
val executeString = function.executeString(*args)
// doubly escape all backslashes to counter some strange escaping and unescaping done by javascript when calling the connector
val executeString = function.executeString(*args).replace("\\", "\\\\")
if (!::browser.isInitialized) {
dispatchQueue.add(executeString)
return
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ interface IOrionExerciseConnector {
* @param testRun true if in a test run, also needed for navigation
* @param base64data data of the zip file containing the student's repository
*/
fun downloadSubmission(submissionId: Long, correctionRound: Long, testRun: Boolean, base64data: String)
// Uncomment this to activate transfer of the testRun flag
// THIS IS A BREAKING CHANGE that will require a matching Artemis version
// fun downloadSubmission(submissionId: Long, correctionRound: Long, testRun: Boolean, base64data: String)
fun downloadSubmission(submissionId: Long, correctionRound: Long, base64data: String)

/**
* Initializes the [OrionAssessmentService] with all current feedback
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,12 @@ class OrionExerciseConnector(val project: Project) : OrionConnector(), IOrionExe
project.service<OrionExerciseService>().assessExercise(exercise)
}

override fun downloadSubmission(submissionId: Long, correctionRound: Long, testRun: Boolean, base64data: String) {
project.service<OrionExerciseService>().downloadSubmission(submissionId, correctionRound, testRun, base64data)
// Uncomment this to activate transfer of the testRun flag
// THIS IS A BREAKING CHANGE that will require a matching Artemis version
// Also uncomment further down
// override fun downloadSubmission(submissionId: Long, correctionRound: Long, testRun: Boolean, base64data: String) {
override fun downloadSubmission(submissionId: Long, correctionRound: Long, base64data: String) {
project.service<OrionExerciseService>().downloadSubmission(submissionId, correctionRound, false, base64data)
}

override fun initializeAssessment(submissionId: Long, feedback: String) {
Expand All @@ -55,8 +59,8 @@ class OrionExerciseConnector(val project: Project) : OrionConnector(), IOrionExe
downloadSubmission(
scanner.nextLine().toLong(),
scanner.nextLine().toLong(),
scanner.nextLine().toBoolean(),
scanner.nextAll()
// scanner.nextLine().toBoolean(),
scanner.nextAll(),
)
} catch (e: OutOfMemoryError) {
// Error handling has to be this high level since the heap size error is thrown by scanner.nextAll()
Expand All @@ -74,7 +78,10 @@ class OrionExerciseConnector(val project: Project) : OrionConnector(), IOrionExe
"editExercise" to listOf("exerciseJson"),
"importParticipation" to listOf("repositoryUrl", "exerciseJson"),
"assessExercise" to listOf("exerciseJson"),
"downloadSubmission" to listOf("submissionId", "correctionRound", "testRun", "downloadURL"),
"downloadSubmission" to listOf(
"submissionId", "correctionRound", //"testRun",
"downloadURL"
),
"initializeAssessment" to listOf("submissionId", "feedback")
)
addLoadHandler(browser, queryInjector, parameterNames)
Expand Down

0 comments on commit 9b916d3

Please sign in to comment.