Skip to content

input sanitization needed for add-header-line! #39

@bremner

Description

@bremner

I have defined the *test form below for use in checkers. It's a bit clunky with one popup per failing test on the client side, but it does the job. Unfortunately I discovered a problem where student exception messages (extracted via exn-message) contain substrings like {post}. This seems to trigger the substitution mechanism, I think in prefix-line/substs. Since it doesn't correspond to a defined substitution, this causes the checker to crash part way through writing out the text file.
I guess some form of escaping is needed, either in my code or in add-header-line!, but that would also need to be handled in subst. Suggestions for workarounds gratefully received.

(define-syntax *test
  (syntax-rules ()
    [(_  expr result)
     (*test expr result equal?)]

    [(_  expr result equal?)
     (with-handlers
       ([exn?
         (λ (exn)
             (add-header-line! "Test failure: <-10>")
             (add-header-line! (format "  --> ~a" (exn-message exn)))
             (message (string-append
                       (exn-message exn)
                       "\nThe submission has been saved with a 10% penalty."
                       "  Fix the test and resubmit to improve your grade")
                      '(ok))
             (message "Handin saved with penalty." 'final))
         ])
       (!test expr result equal?))]))

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions