diff --git a/services/web/app/src/Features/BrandVariations/BrandVariationsHandler.js b/services/web/app/src/Features/BrandVariations/BrandVariationsHandler.js index fa02fba9dc..bcc4d71e25 100644 --- a/services/web/app/src/Features/BrandVariations/BrandVariationsHandler.js +++ b/services/web/app/src/Features/BrandVariations/BrandVariationsHandler.js @@ -1,86 +1,82 @@ -/* eslint-disable - node/handle-callback-err, - max-len, - no-return-assign, - no-unused-vars, -*/ -// TODO: This file was created by bulk-decaffeinate. -// Fix any style issues and re-enable lint. -/* - * decaffeinate suggestions: - * DS102: Remove unnecessary code created because of implicit returns - * DS207: Consider shorter variations of null checks - * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md - */ -let BrandVariationsHandler const OError = require('@overleaf/o-error') const url = require('url') const settings = require('settings-sharelatex') const logger = require('logger-sharelatex') const V1Api = require('../V1/V1Api') +const sanitizeHtml = require('sanitize-html') -module.exports = BrandVariationsHandler = { - getBrandVariationById(brandVariationId, callback) { - if (callback == null) { - callback = function (error, brandVariationDetails) {} - } - if (brandVariationId == null || brandVariationId === '') { - return callback(new Error('Branding variation id not provided')) - } - logger.log({ brandVariationId }, 'fetching brand variation details from v1') - return V1Api.request( - { - uri: `/api/v2/brand_variations/${brandVariationId}` - }, - function (error, response, brandVariationDetails) { - if (error != null) { - OError.tag(error, 'error getting brand variation details', { - brandVariationId - }) - return callback(error) - } - _formatBrandVariationDetails(brandVariationDetails) - return callback(null, brandVariationDetails) - } - ) - } +module.exports = { + getBrandVariationById } -var _formatBrandVariationDetails = function (details) { +function getBrandVariationById(brandVariationId, callback) { + if (brandVariationId == null || brandVariationId === '') { + return callback(new Error('Branding variation id not provided')) + } + logger.log({ brandVariationId }, 'fetching brand variation details from v1') + V1Api.request( + { + uri: `/api/v2/brand_variations/${brandVariationId}` + }, + function (error, response, brandVariationDetails) { + if (error != null) { + OError.tag(error, 'error getting brand variation details', { + brandVariationId + }) + return callback(error) + } + formatBrandVariationDetails(brandVariationDetails) + sanitizeBrandVariationDetails(brandVariationDetails) + callback(null, brandVariationDetails) + } + ) +} + +function formatBrandVariationDetails(details) { if (details.export_url != null) { - details.export_url = _setV1AsHostIfRelativeURL(details.export_url) + details.export_url = setV1AsHostIfRelativeURL(details.export_url) } if (details.home_url != null) { - details.home_url = _setV1AsHostIfRelativeURL(details.home_url) + details.home_url = setV1AsHostIfRelativeURL(details.home_url) } if (details.logo_url != null) { - details.logo_url = _setV1AsHostIfRelativeURL(details.logo_url) + details.logo_url = setV1AsHostIfRelativeURL(details.logo_url) } if (details.journal_guidelines_url != null) { - details.journal_guidelines_url = _setV1AsHostIfRelativeURL( + details.journal_guidelines_url = setV1AsHostIfRelativeURL( details.journal_guidelines_url ) } if (details.journal_cover_url != null) { - details.journal_cover_url = _setV1AsHostIfRelativeURL( + details.journal_cover_url = setV1AsHostIfRelativeURL( details.journal_cover_url ) } if (details.submission_confirmation_page_logo_url != null) { - details.submission_confirmation_page_logo_url = _setV1AsHostIfRelativeURL( + details.submission_confirmation_page_logo_url = setV1AsHostIfRelativeURL( details.submission_confirmation_page_logo_url ) } if (details.publish_menu_icon != null) { - return (details.publish_menu_icon = _setV1AsHostIfRelativeURL( + details.publish_menu_icon = setV1AsHostIfRelativeURL( details.publish_menu_icon - )) + ) } } -var _setV1AsHostIfRelativeURL = urlString => +function sanitizeBrandVariationDetails(details) { + if (details.submit_button_html) { + details.submit_button_html = sanitizeHtml( + details.submit_button_html, + settings.modules.sanitize.options + ) + } +} + +function setV1AsHostIfRelativeURL(urlString) { // The first argument is the base URL to resolve against if the second argument is not absolute. // As it only applies if the second argument is not absolute, we can use it to transform relative URLs into // absolute ones using v1 as the host. If the URL is absolute (e.g. a filepicker one), then the base // argument is just ignored - url.resolve(settings.apis.v1.url, urlString) + return url.resolve(settings.apis.v1.url, urlString) +} diff --git a/services/web/config/settings.defaults.coffee b/services/web/config/settings.defaults.coffee index ac40c0ad43..4d42b0764b 100644 --- a/services/web/config/settings.defaults.coffee +++ b/services/web/config/settings.defaults.coffee @@ -718,6 +718,7 @@ module.exports = settings = 'img': [ 'alt', 'class', 'src', 'style' ] 'source': [ 'src', 'type' ] 'span': [ 'class', 'id', 'style' ] + 'strong': [ 'style' ] 'table': [ 'border', 'class', 'id', 'style' ] 'td': [ 'colspan', 'rowspan', 'headers', 'style' ] 'th': [ 'abbr', 'headers', 'colspan', 'rowspan', 'scope', 'sorted', 'style' ] @@ -728,6 +729,7 @@ module.exports = settings = # modules to import (an empty array for each set of modules) createFileModes: [] gitBridge: [] + publishModal: [] } csp: { diff --git a/services/web/frontend/extracted-translations.json b/services/web/frontend/extracted-translations.json index 4ec8d5de7b..12bf485eab 100644 --- a/services/web/frontend/extracted-translations.json +++ b/services/web/frontend/extracted-translations.json @@ -212,6 +212,7 @@ "stop_compile": "", "stop_on_validation_error": "", "store_your_work": "", + "submit": "", "sure_you_want_to_delete": "", "sync_project_to_github_explanation": "", "sync_to_dropbox": "", diff --git a/services/web/frontend/js/features/editor-navigation-toolbar/components/toolbar-header.js b/services/web/frontend/js/features/editor-navigation-toolbar/components/toolbar-header.js index 9c255d8997..41a40fcd1f 100644 --- a/services/web/frontend/js/features/editor-navigation-toolbar/components/toolbar-header.js +++ b/services/web/frontend/js/features/editor-navigation-toolbar/components/toolbar-header.js @@ -10,6 +10,10 @@ import TrackChangesToggleButton from './track-changes-toggle-button' import HistoryToggleButton from './history-toggle-button' import ShareProjectButton from './share-project-button' import PdfToggleButton from './pdf-toggle-button' +import importOverleafModules from '../../../../macros/import-overleaf-module.macro' + +const [publishModalModules] = importOverleafModules('publishModal') +const PublishButton = publishModalModules?.import.default function ToolbarHeader({ cobranding, @@ -53,14 +57,18 @@ function ToolbarHeader({