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

Don't HTML encode quotes in REST API callback, to fix ONKI Selector (Skosmos 2) #1705

Merged
merged 1 commit into from
Oct 29, 2024

Conversation

osma
Copy link
Member

@osma osma commented Oct 29, 2024

Reasons for creating this PR

ONKI Selector (the legacy JS widget for accessing ONKI/Finto vocabularies) wasn't working, because it uses the callback parameter with a value that includes quote characters. The input sanitizing that was quite recently added to RestController broke this functionality.

The symptom is that the Skosmos REST API, when called with a URL like https://api.finto.fi/rest/v1/yso/?callback=onkiSearch["ysoSearch"].setRestLangs , generates a response like this: onkiSearch["ysoSearch"].setRestLangs(...) and this causes a JS syntax error. (Uncaught SyntaxError: expected expression, got '&')

This PR fixes the problem by preventing the HTML encoding of quote characters.

Link to relevant issue(s), if any

  • n/a

Description of the changes in this PR

Known problems or uncertainties in this PR

Not sure if the input sanitizing for the callback parameter (which is needed for generating JS, not HTML) is a great idea in the first place, but at least this fixes the issue with quotes.

Checklist

  • phpUnit tests pass locally with my changes
  • I have added tests that show that the new code works, or tests are not relevant for this PR (e.g. only HTML/CSS changes)
  • The PR doesn't reduce accessibility of the front-end code (e.g. tab focus, scaling to different resolutions, use of .sr-only class, color contrast)
  • The PR doesn't introduce unintended code changes (e.g. empty lines or useless reindentation)

@osma osma added bug REST Skosmos 2.X Relevant for Skosmos 2 labels Oct 29, 2024
@osma osma added this to the 2.x milestone Oct 29, 2024
@osma osma self-assigned this Oct 29, 2024
Copy link

sonarcloud bot commented Oct 29, 2024

Quality Gate Failed Quality Gate failed

Failed conditions
E Security Rating on New Code (required ≥ A)

See analysis details on SonarCloud

Catch issues before they fail your Quality Gate with our IDE extension SonarLint

@osma osma merged commit 6073feb into skosmos-2 Oct 29, 2024
4 of 8 checks passed
@osma osma deleted the fix-rest-callback-quotes-skosmos-2 branch October 29, 2024 13:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug REST Skosmos 2.X Relevant for Skosmos 2
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant