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

pkp#28: provide backend header support [3.3] #29

Merged
merged 2 commits into from
Oct 11, 2023

Conversation

ctgraham
Copy link
Contributor

@ctgraham ctgraham commented May 2, 2023

Resolves #28 for 3.3; C.f. forward port to main.

@ctgraham ctgraham changed the title pkp#28: provide backend header support pkp#28: provide backend header support [main] May 2, 2023
@ctgraham ctgraham changed the title pkp#28: provide backend header support [main] pkp#28: provide backend header support [3.3] May 2, 2023
$libxml_errors_setting = libxml_use_internal_errors();
libxml_use_internal_errors(true);
libxml_clear_errors();
$xml = simplexml_load_string($input);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a thought -- is this going to be overly restrictive? It's requiring well-formed XML, but the field should be checking for well-formed HTML. I think the DOM tools might provide an alternative:

https://www.php.net/manual/en/domdocument.loadhtml.php

The idea would be:

  1. Use the same libxml_use_internal_errors approach and return value to determine whether a fatal parsing error occurred
  2. If it's flexible enough to allow parsing of documents that we don't want to permit, maybe re-serialize the HTML before storing in the setting to resolve that?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair enough. It's unlikely that someone would want to legitimately throw an unclosed li in the head, but I could see someone wanting to do an old-style meta tag perhaps.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ctgraham, unfortunately it looks like this won't work well. See:

#33

I'll follow up on that issue.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps and additional checkbox or a second confirmation "submit" which bypasses the validation? A "I solemnly swear I am up to no good" prompt?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ctgraham, that sounds OK to me (and I'm not sure we'll find a better solution). I did find an OK-looking work-around that gets the validator to pass without breaking the JS, which I described here.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"I solemnly swear I am up to no good" 🧙‍♂️ totally yes! After all who doesn't know that "with great power comes great responsibility"?

@asmecher asmecher merged commit d830752 into pkp:stable-3_3_0 Oct 11, 2023
1 check passed
@ctgraham ctgraham deleted the issue-28 branch December 22, 2023 21:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants