From 42032f5e9aac23b6abec5c07b6a975fbe695dd0a Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Sun, 7 May 2017 10:00:38 +0300 Subject: [PATCH] Improve JSON encoding in HTML --- app/Http/Requests/SaveClientPortalSettings.php | 4 ++-- app/Libraries/HTMLUtils.php | 15 ++++++++++++++- resources/views/accounts/client_portal.blade.php | 2 +- resources/views/accounts/invoice_design.blade.php | 2 +- resources/views/accounts/payments.blade.php | 2 +- .../accounts/templates_and_reminders.blade.php | 2 +- resources/views/clients/statement.blade.php | 4 ++-- resources/views/credits/edit.blade.php | 2 +- resources/views/dashboard.blade.php | 2 +- resources/views/expenses/edit.blade.php | 8 ++++---- resources/views/invoices/edit.blade.php | 12 ++++++------ resources/views/invoices/history.blade.php | 2 +- resources/views/invoices/knockout.blade.php | 4 ++-- resources/views/invoices/pdf.blade.php | 2 +- resources/views/invoices/view.blade.php | 6 +++--- resources/views/payments/edit.blade.php | 4 ++-- .../views/payments/paymentmethods_list.blade.php | 2 +- resources/views/projects/edit.blade.php | 2 +- resources/views/reports/d3.blade.php | 2 +- resources/views/tasks/edit.blade.php | 4 ++-- 20 files changed, 48 insertions(+), 35 deletions(-) diff --git a/app/Http/Requests/SaveClientPortalSettings.php b/app/Http/Requests/SaveClientPortalSettings.php index 7912c0df45da..cd81bf7d31dd 100644 --- a/app/Http/Requests/SaveClientPortalSettings.php +++ b/app/Http/Requests/SaveClientPortalSettings.php @@ -38,7 +38,7 @@ class SaveClientPortalSettings extends Request $input = $this->all(); if ($this->client_view_css && Utils::isNinja()) { - $input['client_view_css'] = HTMLUtils::sanitize($this->client_view_css); + $input['client_view_css'] = HTMLUtils::sanitizeCSS($this->client_view_css); } if (Utils::isNinja()) { @@ -53,7 +53,7 @@ class SaveClientPortalSettings extends Request $input['subdomain'] = null; } } - + $this->replace($input); return $this->all(); diff --git a/app/Libraries/HTMLUtils.php b/app/Libraries/HTMLUtils.php index 412252a1eb6d..3e3252a922ca 100644 --- a/app/Libraries/HTMLUtils.php +++ b/app/Libraries/HTMLUtils.php @@ -7,7 +7,7 @@ use HTMLPurifier_Config; class HTMLUtils { - public static function sanitize($css) + public static function sanitizeCSS($css) { // Allow referencing the body element $css = preg_replace('/(?purify($html); + } + + public static function encodeJSON($string) + { + return htmlentities(json_encode($string), ENT_NOQUOTES); + } } diff --git a/resources/views/accounts/client_portal.blade.php b/resources/views/accounts/client_portal.blade.php index 71fa231e65e2..22debed199ac 100644 --- a/resources/views/accounts/client_portal.blade.php +++ b/resources/views/accounts/client_portal.blade.php @@ -372,7 +372,7 @@ iframe.src = '{{ rtrim(SITE_URL ,'/') }}/view/'