Merge pull request #1862 from overleaf/em-json-stringify

Globally apply StringHelper.stringifyJsonForScript()

GitOrigin-RevId: 82dc812a43a1e6f389471380a6a430c0a18dcec2
This commit is contained in:
Simon Detheridge 2019-06-17 15:46:52 +01:00 committed by sharelatex
parent 321d66f804
commit 82672269c4
12 changed files with 18 additions and 21 deletions

View file

@ -66,17 +66,17 @@ html(
jsPath: '#{jsPath}',
sixpackDomain: '#{settings.sixpack.domain}'
};
window.systemMessages = !{JSON.stringify(systemMessages).replace(/\//g, '\\/')};
window.systemMessages = !{StringHelper.stringifyJsonForScript(systemMessages)};
window.ab = {};
window.user_id = '#{getLoggedInUserId()}';
window.ExposedSettings = JSON.parse('!{JSON.stringify(ExposedSettings).replace(/\//g, "\\/")}');
window.ExposedSettings = JSON.parse('!{StringHelper.stringifyJsonForScript(ExposedSettings)}');
- if (typeof(settings.algolia) != "undefined")
script.
window.sharelatex.algolia = {
app_id:'#{settings.algolia.app_id}',
api_key:'#{settings.algolia.read_only_api_key}',
indexes:!{JSON.stringify(settings.algolia.indexes)}
indexes:!{StringHelper.stringifyJsonForScript(settings.algolia.indexes)}
}
- if (typeof(settings.templates) != "undefined")

View file

@ -116,7 +116,7 @@ block requirejs
//- We need to do .replace(/\//g, '\\/') do that '</script>' -> '<\/script>'
//- and doesn't prematurely end the script tag.
script#data(type="application/json").
!{JSON.stringify({userSettings: userSettings, user: user, trackChangesState: trackChangesState, useV2History: useV2History, enabledLinkedFileTypes: settings.enabledLinkedFileTypes, brandVariation: brandVariation}).replace(/\//g, '\\/')}
!{StringHelper.stringifyJsonForScript({ userSettings: userSettings, user: user, trackChangesState: trackChangesState, useV2History: useV2History, enabledLinkedFileTypes: settings.enabledLinkedFileTypes, brandVariation: brandVariation })}
script(type="text/javascript").
window.data = JSON.parse($("#data").text());
@ -174,14 +174,14 @@ block requirejs
};
window.aceWorkerPath = "#{aceWorkerPath}";
window.pdfCMapsPath = "#{pdfCMapsPath}"
window.uiConfig = JSON.parse('!{JSON.stringify(uiConfig).replace(/\//g, "\\/")}');
window.uiConfig = JSON.parse('!{StringHelper.stringifyJsonForScript(uiConfig)}');
//- enable doc hash checking for projects created after 2019-06-09
//- this is for a staged rollout, eventually we will turn this on for all projects
window.useShareJsHash = (window.project_id > "5cfd8f700000000000000000")
- if (settings.overleaf != null)
script(type='text/javascript').
window.overallThemes = JSON.parse('!{JSON.stringify(overallThemes).replace(/\//g, "\\/")}');
window.overallThemes = JSON.parse('!{StringHelper.stringifyJsonForScript(overallThemes)}');
script(
data-main=buildJsPath("ide.js", {hashedPath:false}),

View file

@ -4,11 +4,8 @@ block vars
- var suppressNavContentLinks = true
block content
//- We need to do .replace(/\//g, '\\/') do that '</script>' -> '<\/script>'
//- and doesn't prematurely end the script tag.
script#data(type="application/json").
!{JSON.stringify({ projects: projects, tags: tags, notifications: notifications }).replace(/\//g, '\\/')}
!{StringHelper.stringifyJsonForScript({ projects, tags, notifications })}
script(type="text/javascript").
window.data = JSON.parse($("#data").text());

View file

@ -1,5 +1,5 @@
script(type='text/javascript').
window.managedInstitutions = !{JSON.stringify(managedInstitutions)}
window.managedInstitutions = !{StringHelper.stringifyJsonForScript(managedInstitutions)}
each institution in managedInstitutions
p

View file

@ -1,7 +1,7 @@
script(src="https://js.recurly.com/v3/recurly.js")
script(type='text/javascript').
window.recurlyApiKey = "!{settings.apis.recurly.publicKey}"
window.subscription = !{JSON.stringify(personalSubscription)}
window.subscription = !{StringHelper.stringifyJsonForScript(personalSubscription)}
window.recomendedCurrency = "#{personalSubscription.recurly.currency}"
div(ng-controller="RecurlySubscriptionController")

View file

@ -5,8 +5,8 @@ block scripts
window.countryCode = '#{countryCode}'
window.plan_code = '#{plan_code}'
window.recurlyApiKey = "!{settings.apis.recurly.publicKey}"
window.couponCode = !{JSON.stringify(couponCode)}
window.recomendedCurrency = !{JSON.stringify(currency.slice(0,3))}
window.couponCode = !{StringHelper.stringifyJsonForScript(couponCode)}
window.recomendedCurrency = !{StringHelper.stringifyJsonForScript(currency.slice(0,3))}
block content
.content.content-alt

View file

@ -10,7 +10,7 @@ block scripts
script(type='text/javascript').
window.recomendedCurrency = '#{recomendedCurrency}';
window.abCurrencyFlag = '#{abCurrencyFlag}';
window.groupPlans = !{JSON.stringify(groupPlans)};
window.groupPlans = !{StringHelper.stringifyJsonForScript(groupPlans)};
block content
.content.content-alt.content-page

View file

@ -61,4 +61,4 @@ block content
span(ng-show="activationForm.inflight") #{translate("activating")}...
script(type='text/javascript').
window.passwordStrengthOptions = !{JSON.stringify(settings.passwordStrengthOptions || {})}
window.passwordStrengthOptions = !{StringHelper.stringifyJsonForScript(settings.passwordStrengthOptions || {})}

View file

@ -3,7 +3,7 @@ extends ../layout
block scripts
script(type='text/javascript').
window.otherSessions = !{JSON.stringify(sessions)}
window.otherSessions = !{StringHelper.stringifyJsonForScript(sessions)}
block content

View file

@ -60,4 +60,4 @@ block content
script(type='text/javascript').
window.usersEmail = "#{getReqQueryParam('email')}"
window.passwordStrengthOptions = !{JSON.stringify(settings.passwordStrengthOptions || {})}
window.passwordStrengthOptions = !{StringHelper.stringifyJsonForScript(settings.passwordStrengthOptions || {})}

View file

@ -292,4 +292,4 @@ block content
span(ng-show="state.inflight") #{translate("deleting")}...
script(type='text/javascript').
window.passwordStrengthOptions = !{JSON.stringify(settings.passwordStrengthOptions || {})}
window.passwordStrengthOptions = !{StringHelper.stringifyJsonForScript(settings.passwordStrengthOptions || {})}

View file

@ -103,6 +103,6 @@ block content
script(type="text/javascript").
window.users = !{JSON.stringify(users)};
window.paths = !{JSON.stringify(paths)};
window.users = !{StringHelper.stringifyJsonForScript(users)};
window.paths = !{StringHelper.stringifyJsonForScript(paths)};
window.groupSize = #{groupSize || 'null'};