From cf1c0d50d55e686dbb722b8f4de85b543ae2e5e1 Mon Sep 17 00:00:00 2001 From: LucasC Date: Fri, 22 Nov 2024 14:58:50 +0100 Subject: [PATCH] XWIKI-22205: Underline inline link in CSRF confirmation Panel (#3200) * Deprecated the old translation key that contained HTML syntax * Replaced it with a juxtaposition of smaller translations. * When nesting was needed, used parameters to make sure we don't have syntax inside the translation values. * Updated the two uses of the old translation key --- .../resources/ApplicationResources.properties | 9 +++++++- .../src/main/resources/templates/resubmit.vm | 23 ++++++++++++++++++- .../js/xwiki/actionbuttons/actionButtons.js | 10 +++++++- 3 files changed, 39 insertions(+), 3 deletions(-) diff --git a/xwiki-platform-core/xwiki-platform-oldcore/src/main/resources/ApplicationResources.properties b/xwiki-platform-core/xwiki-platform-oldcore/src/main/resources/ApplicationResources.properties index cafdfc266d5b..7be876c6c294 100644 --- a/xwiki-platform-core/xwiki-platform-oldcore/src/main/resources/ApplicationResources.properties +++ b/xwiki-platform-core/xwiki-platform-oldcore/src/main/resources/ApplicationResources.properties @@ -3640,7 +3640,13 @@ XWiki.SearchSuggestSourceClass_activated=Activated XWiki.SearchSuggestSourceClass_activated.hint=Whether this source is used or not (as long as the source search engine matches the search engine used by the current wiki). ### CSRFToken resources -csrf.confirmation=

This request contains an invalid authentication information.

This might happen in the following situations:

If you are sure that none of these situations apply in your case, you might have found a bug. We are sorry about that, please report it on XWiki JIRA

Do you want to resend the request? If unsure, say No.

+csrf.confirmation.status=This request contains an invalid authentication information. +csrf.confirmation.possibleReasons.description=This might happen in the following situations: +csrf.confirmation.possibleReasons.firstReason=You left the editor open in another window/tab and logged off and on again +csrf.confirmation.possibleReasons.secondReason=Your authentication token expired after a long period of inactivity +csrf.confirmation.possibleReasons.thirdReason=Somebody tried to perform a CSRF attack +csrf.confirmation.unsure=If you are sure that none of these situations apply in your case, you might have found a bug. We are sorry about that, please report it on {0}XWiki JIRA{1}. +csrf.confirmation.question=Do you want to resend the request? If unsure, say {0}No{1}. ### Extension Manager application resources admin.extensions=Extension Manager @@ -5667,6 +5673,7 @@ platform.index.spaceIndexDocumentListCreate=Create a new page ####################################### ## until 16.10.0RC1 ####################################### +csrf.confirmation=

This request contains an invalid authentication information.

This might happen in the following situations:

If you are sure that none of these situations apply in your case, you might have found a bug. We are sorry about that, please report it on XWiki JIRA

Do you want to resend the request? If unsure, say No.

core.register.successful={0} ({1}): Registration successful. ## Used to indicate where deprecated keys end diff --git a/xwiki-platform-core/xwiki-platform-web/xwiki-platform-web-templates/src/main/resources/templates/resubmit.vm b/xwiki-platform-core/xwiki-platform-web/xwiki-platform-web-templates/src/main/resources/templates/resubmit.vm index b7ddce0f9084..ff3ac9cf2150 100644 --- a/xwiki-platform-core/xwiki-platform-web/xwiki-platform-web-templates/src/main/resources/templates/resubmit.vm +++ b/xwiki-platform-core/xwiki-platform-web/xwiki-platform-web-templates/src/main/resources/templates/resubmit.vm @@ -29,7 +29,28 @@ $response.addHeader( "X-FRAME-OPTIONS", "DENY" )
## Set as an HTML main for better DOM tree semantics to facilitate navigation with assistive technologies.
-#xwikimessageboxstart($services.localization.render('warning') $services.localization.render('csrf.confirmation')) +#define ($messageBoxContent) +

+$services.localization.render('csrf.confirmation.status') +

+

+$services.localization.render('csrf.confirmation.possibleReasons.description') +

+
  • +$services.localization.render('csrf.confirmation.possibleReasons.firstReason') +
  • +$services.localization.render('csrf.confirmation.possibleReasons.secondReason') +
  • +$services.localization.render('csrf.confirmation.possibleReasons.thirdReason') +
+

+$services.localization.render('csrf.confirmation.unsure', ["", ""]) +

+

+$services.localization.render('csrf.confirmation.question', ["", ""]) +

+#end +#xwikimessageboxstart($services.localization.render('warning') $messageBoxContent) #getSanitizedURLAttributeValue('form','action', $request.getParameter('resubmit'), '', $resubmit) #getSanitizedURLAttributeValue('a','href', $request.getParameter('xback'), $doc.getURL(), $xback)
diff --git a/xwiki-platform-core/xwiki-platform-web/xwiki-platform-web-war/src/main/webapp/resources/js/xwiki/actionbuttons/actionButtons.js b/xwiki-platform-core/xwiki-platform-web/xwiki-platform-web-war/src/main/webapp/resources/js/xwiki/actionbuttons/actionButtons.js index 3c540216bfaa..5fd2851a1476 100644 --- a/xwiki-platform-core/xwiki-platform-web/xwiki-platform-web-war/src/main/webapp/resources/js/xwiki/actionbuttons/actionButtons.js +++ b/xwiki-platform-core/xwiki-platform-web/xwiki-platform-web-war/src/main/webapp/resources/js/xwiki/actionbuttons/actionButtons.js @@ -529,7 +529,15 @@ var XWiki = (function(XWiki) { var buttonsDiv = new Element('div'); // the confirmation message contains some double quotes that should be escaped. - content.insert("$escapetool.json($services.localization.render('csrf.confirmation'))"); + content.insert("

$services.localization.render('csrf.confirmation.status')

" + + "

$services.localization.render('csrf.confirmation.possibleReasons.description')

" + + "
  • $services.localization.render('csrf.confirmation.possibleReasons.firstReason')
  • " + + "
  • $services.localization.render('csrf.confirmation.possibleReasons.secondReason')
  • " + + "
  • $services.localization.render('csrf.confirmation.possibleReasons.thirdReason')
" + + "

" + + "$services.localization.render('csrf.confirmation.unsure', ["", ""])" + + "

" + + "

$services.localization.render('csrf.confirmation.question', ['', ''])

"); content.insert(new Element('br')); var buttonCreate = new Element('button', {'class': 'btn btn-default', 'id': 'force-save-csrf'}); buttonCreate.insert("$services.localization.render('yes')");