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/pkp-lib#2564 Submission title and sub title with HTML tag handling #25

Merged
merged 2 commits into from
Feb 16, 2023

Conversation

touhidurabir
Copy link
Member

This PR aims to provide solution for pkp/pkp-lib#2564

@@ -113,8 +113,8 @@ public function createJournalArticleNode($doc, $submission)

// title
$titlesNode = $doc->createElementNS($deployment->getNamespace(), 'titles');
$titlesNode->appendChild($node = $doc->createElementNS($deployment->getNamespace(), 'title', htmlspecialchars($publication->getLocalizedTitle($locale), ENT_COMPAT, 'UTF-8')));
if ($subtitle = $publication->getData('subtitle', $locale)) {
$titlesNode->appendChild($node = $doc->createElementNS($deployment->getNamespace(), 'title', htmlspecialchars($publication->getLocalizedTitle($locale, 'html'), ENT_COMPAT, 'UTF-8')));
Copy link
Member

Choose a reason for hiding this comment

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

I think this will lead these fields to be double-escaped. A title containing markup should look like:

<title>E=mc<sup>2</sup></title>

...but the call to htmlspecialchars will cause it to look like...

<title>E=mc&lt;sup&gt;2&lt;/sup&gt;</title>

Copy link
Member Author

Choose a reason for hiding this comment

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

@asmecher htmlspecialchars was there before my changes . Was that a mistake ? Also considering the following title

<title>Albert Einstein great formula "E=MC<sup>2</sup>" allow us to measure the released energy by nuclear fusion</title>

Do we allow quotes(single or double) in title ?

Copy link
Member

Choose a reason for hiding this comment

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

htmlspecialchars made sense with plaintext content (it will make sure that < > & will be interpreted as text characters, not HTML entities) but now that we're allowing HTML it'll need to be changed for the appropriate filtering function. We do allow quotes in titles.

@asmecher asmecher merged commit 0722167 into pkp:main Feb 16, 2023
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.

2 participants