Skip to content

Commit

Permalink
Fix vars.js broken when custom translation contains quotes - closes #…
Browse files Browse the repository at this point in the history
  • Loading branch information
freescout-help-desk committed Nov 30, 2024
1 parent 3562298 commit df0ab1a
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions app/Console/Commands/GenerateVars.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,17 @@ public function handle()

$content = view('js/vars', $params)->render();

//$filesystem->put($file_path, $content);
// Save vars only if content changed
// Escape quotes in json values.
// https://github.com/freescout-help-desk/freescout/issues/4369
$content = preg_replace_callback(
"#(:[ ]*\")(.*)(\"[,\r\n])#",
function($v) {
return $v[1].str_replace('"', '\"', $v[2]).$v[3];
},
$content
);

// Save vars only if content has changed.
try {
if (\Storage::exists('js/vars.js')) {
$old_content = \Storage::get('js/vars.js');
Expand Down

0 comments on commit df0ab1a

Please sign in to comment.