Quellcode durchsuchen

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

Globally apply StringHelper.stringifyJsonForScript()

GitOrigin-RevId: 82dc812a43a1e6f389471380a6a430c0a18dcec2
Simon Detheridge vor 7 Jahren
Ursprung
Commit
82672269c4

+ 3 - 3
services/web/app/views/layout.pug

@@ -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")

+ 3 - 3
services/web/app/views/project/editor.pug

@@ -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}),

+ 1 - 4
services/web/app/views/project/list.pug

@@ -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());

+ 1 - 1
services/web/app/views/subscriptions/dashboard/_managed_institutions.pug

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

+ 1 - 1
services/web/app/views/subscriptions/dashboard/_personal_subscription_recurly.pug

@@ -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")

+ 2 - 2
services/web/app/views/subscriptions/new.pug

@@ -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

+ 1 - 1
services/web/app/views/subscriptions/plans.pug

@@ -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

+ 1 - 1
services/web/app/views/user/activate.pug

@@ -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 || {})}

+ 1 - 1
services/web/app/views/user/sessions.pug

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

+ 1 - 1
services/web/app/views/user/setPassword.pug

@@ -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 || {})}

+ 1 - 1
services/web/app/views/user/settings.pug

@@ -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 || {})}

+ 2 - 2
services/web/app/views/user_membership/index.pug

@@ -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'};