Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix: Fix json escaping #74

Merged
merged 3 commits into from
Nov 19, 2021
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 @@ -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