public inbox for pbs-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [pbs-devel] [PATCH proxmox-backup 1/2] server/email_notifications: do not double html escape
@ 2021-03-17 14:19 Dominik Csapak
  2021-03-17 14:19 ` [pbs-devel] [PATCH proxmox-backup 2/2] tools/subscription: ignore ENOENT for apt auth config removal Dominik Csapak
  2021-03-17 19:39 ` [pbs-devel] [PATCH proxmox-backup 1/2] server/email_notifications: do not double html escape Thomas Lamprecht
  0 siblings, 2 replies; 4+ messages in thread
From: Dominik Csapak @ 2021-03-17 14:19 UTC (permalink / raw)
  To: pbs-devel

the default escape handler is handlebars::html_escape, but this are
plain text emails and we manually escape them for the html part, so
set the default escape handler to 'no_escape'

this avoids double html escape for the characters: '&"<>' in emails

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
 src/server/email_notifications.rs | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/server/email_notifications.rs b/src/server/email_notifications.rs
index 70e13053..2acee538 100644
--- a/src/server/email_notifications.rs
+++ b/src/server/email_notifications.rs
@@ -194,6 +194,7 @@ lazy_static::lazy_static!{
         let result: Result<(), TemplateError> = try_block!({
 
             hb.set_strict_mode(true);
+            hb.register_escape_fn(handlebars::no_escape);
 
             hb.register_helper("human-bytes", Box::new(handlebars_humam_bytes_helper));
             hb.register_helper("relative-percentage", Box::new(handlebars_relative_percentage_helper));
-- 
2.20.1





^ permalink raw reply	[flat|nested] 4+ messages in thread

* [pbs-devel] [PATCH proxmox-backup 2/2] tools/subscription: ignore ENOENT for apt auth config removal
  2021-03-17 14:19 [pbs-devel] [PATCH proxmox-backup 1/2] server/email_notifications: do not double html escape Dominik Csapak
@ 2021-03-17 14:19 ` Dominik Csapak
  2021-03-17 19:38   ` [pbs-devel] applied: " Thomas Lamprecht
  2021-03-17 19:39 ` [pbs-devel] [PATCH proxmox-backup 1/2] server/email_notifications: do not double html escape Thomas Lamprecht
  1 sibling, 1 reply; 4+ messages in thread
From: Dominik Csapak @ 2021-03-17 14:19 UTC (permalink / raw)
  To: pbs-devel

deleting a nonexistant file is hardly an error worth mentioning

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
 src/tools/subscription.rs | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/src/tools/subscription.rs b/src/tools/subscription.rs
index 07c6b40f..9b9534ac 100644
--- a/src/tools/subscription.rs
+++ b/src/tools/subscription.rs
@@ -318,8 +318,11 @@ pub fn update_apt_auth(key: Option<String>, password: Option<String>) -> Result<
             replace_file(auth_conf, conf.as_bytes(), file_opts)
                 .map_err(|e| format_err!("Error saving apt auth config - {}", e))?;
         }
-        _ => nix::unistd::unlink(auth_conf)
-            .map_err(|e| format_err!("Error clearing apt auth config - {}", e))?,
+        _ => match nix::unistd::unlink(auth_conf) {
+            Ok(()) => Ok(()),
+            Err(nix::Error::Sys(nix::errno::Errno::ENOENT)) => Ok(()), // ignore not existing
+            Err(err) => Err(err),
+        }.map_err(|e| format_err!("Error clearing apt auth config - {}", e))?,
     }
     Ok(())
 }
-- 
2.20.1





^ permalink raw reply	[flat|nested] 4+ messages in thread

* [pbs-devel] applied: [PATCH proxmox-backup 2/2] tools/subscription: ignore ENOENT for apt auth config removal
  2021-03-17 14:19 ` [pbs-devel] [PATCH proxmox-backup 2/2] tools/subscription: ignore ENOENT for apt auth config removal Dominik Csapak
@ 2021-03-17 19:38   ` Thomas Lamprecht
  0 siblings, 0 replies; 4+ messages in thread
From: Thomas Lamprecht @ 2021-03-17 19:38 UTC (permalink / raw)
  To: Proxmox Backup Server development discussion, Dominik Csapak

On 17.03.21 15:19, Dominik Csapak wrote:
> deleting a nonexistant file is hardly an error worth mentioning
> 
> Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
> ---
>  src/tools/subscription.rs | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
> 
>

applied, thanks!




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [pbs-devel] [PATCH proxmox-backup 1/2] server/email_notifications: do not double html escape
  2021-03-17 14:19 [pbs-devel] [PATCH proxmox-backup 1/2] server/email_notifications: do not double html escape Dominik Csapak
  2021-03-17 14:19 ` [pbs-devel] [PATCH proxmox-backup 2/2] tools/subscription: ignore ENOENT for apt auth config removal Dominik Csapak
@ 2021-03-17 19:39 ` Thomas Lamprecht
  1 sibling, 0 replies; 4+ messages in thread
From: Thomas Lamprecht @ 2021-03-17 19:39 UTC (permalink / raw)
  To: Proxmox Backup Server development discussion, Dominik Csapak

On 17.03.21 15:19, Dominik Csapak wrote:
> the default escape handler is handlebars::html_escape, but this are
> plain text emails and we manually escape them for the html part, so
> set the default escape handler to 'no_escape'
> 
> this avoids double html escape for the characters: '&"<>' in emails
> 
> Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
> ---
>  src/server/email_notifications.rs | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/src/server/email_notifications.rs b/src/server/email_notifications.rs
> index 70e13053..2acee538 100644
> --- a/src/server/email_notifications.rs
> +++ b/src/server/email_notifications.rs
> @@ -194,6 +194,7 @@ lazy_static::lazy_static!{
>          let result: Result<(), TemplateError> = try_block!({
>  
>              hb.set_strict_mode(true);
> +            hb.register_escape_fn(handlebars::no_escape);
>  
>              hb.register_helper("human-bytes", Box::new(handlebars_humam_bytes_helper));
>              hb.register_helper("relative-percentage", Box::new(handlebars_relative_percentage_helper));
> 

for the record: This would need "server/email_notifications: do not panic on template registration"
to be applied before, else it does not applies.




^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-03-17 19:39 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-17 14:19 [pbs-devel] [PATCH proxmox-backup 1/2] server/email_notifications: do not double html escape Dominik Csapak
2021-03-17 14:19 ` [pbs-devel] [PATCH proxmox-backup 2/2] tools/subscription: ignore ENOENT for apt auth config removal Dominik Csapak
2021-03-17 19:38   ` [pbs-devel] applied: " Thomas Lamprecht
2021-03-17 19:39 ` [pbs-devel] [PATCH proxmox-backup 1/2] server/email_notifications: do not double html escape Thomas Lamprecht

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal