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

Images are not shown in output #66

Closed
niknetniko opened this issue Mar 9, 2023 · 4 comments
Closed

Images are not shown in output #66

niknetniko opened this issue Mar 9, 2023 · 4 comments
Assignees
Labels
bug Something isn't working

Comments

@niknetniko
Copy link
Member

When submitting solutions for the Turtle judge, I can't seem to get the images to work:

image

Tested in both Firefox and Chrome.

(Not entirely sure if this is a turtle judge issue or a Dodona issue, but I'll move the issue to the correct repo if necessary)

@niknetniko niknetniko added the bug Something isn't working label Mar 9, 2023
@BTWS2
Copy link
Collaborator

BTWS2 commented Mar 27, 2023

Thank you for notifying me. Images form submissions that worked correctly in the past are also gone (e.g. https://dodona.ugent.be/nl/submissions/11622640/), but the code from the judge didn't change. This leads me to believe this is a Dodona issue.

@jorg-vr
Copy link

jorg-vr commented Sep 28, 2023

Summary of slack discussion:

data:image/svg+xml is no longer supported due to security concerns (see rails/rails-html-sanitizer#147)

I suggest to render svg's inline instead of as an image. This allows for proper sanitizing by rails.

@jorg-vr
Copy link

jorg-vr commented Sep 28, 2023

In the code png versions of the images are calculated but never used, so using this might be an option as well if simply inlining the svg does not work. (But inlining the svg still seems prefered as it would also lower complexity of the judge)

png_submission = generate_png_image(svg_submission, config.canvas_width, config.canvas_height)
png_solution = generate_png_image(svg_solution, config.canvas_width, config.canvas_height)
correct_pixels, total_pixels, expected_total = diff_images(png_submission, png_solution)
base64_submission = base64.b64encode(svg_submission).decode("utf-8")
base64_solution = base64.b64encode(svg_solution).decode("utf-8")
html = f"""
<div style="display:inline-block;width:50%;">
<p style="padding:10px">{config.translator.translate(Translator.Text.SUBMISSION_TITLE)}</p>
<img
alt="submission result"
style="width:98%;background-color:#fff"
src="data:image/svg+xml;base64,{base64_submission}" />
</div>
<div style="display:inline-block;float:right;width:50%;">
<p style="padding:10px">{config.translator.translate(Translator.Text.SOLUTION_TITLE)}</p>
<img
alt="solution result"
style="width:98%;background-color:#fff"
src="data:image/svg+xml;base64,{base64_solution}" />
</div>
"""

@BTWS2 BTWS2 self-assigned this Oct 8, 2024
@BTWS2
Copy link
Collaborator

BTWS2 commented Oct 10, 2024

data:image/svg+xml is no longer supported due to security concerns. SVG's are now shown inline. This commit fixed the render: 39bd9cf.

The polyline tag wasn't allowed as a tag. This was fixed by: dodona-edu/dodona#5853.

@BTWS2 BTWS2 closed this as completed Oct 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants