From c18212f9ef16b6c8e43847b4bf41dd5a935c20fb Mon Sep 17 00:00:00 2001 From: Ultrabug Date: Sun, 2 Oct 2022 17:08:33 +0200 Subject: [PATCH] formatter: add escape command to escape html * google_calendar module: let users decide if they want to escape or not --- py3status/formatter.py | 3 +++ py3status/modules/google_calendar.py | 3 +-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/py3status/formatter.py b/py3status/formatter.py index 9b8659a725..b266d02c3d 100644 --- a/py3status/formatter.py +++ b/py3status/formatter.py @@ -1,4 +1,5 @@ import re +from html import escape from math import ceil from numbers import Number from urllib.parse import parse_qsl @@ -322,6 +323,8 @@ def get(self, get_params, block): # no remaining digits following it. If the parameter cannot # be successfully converted then the format will be removed. try: + if "escape" in self.format: + value = escape(value) if "ceil" in self.format: value = ceil(float(value)) if "f" in self.format: diff --git a/py3status/modules/google_calendar.py b/py3status/modules/google_calendar.py index 2f09734a54..cb4ebbc0ec 100644 --- a/py3status/modules/google_calendar.py +++ b/py3status/modules/google_calendar.py @@ -154,7 +154,6 @@ import datetime import time from pathlib import Path -from html import escape try: from googleapiclient import discovery @@ -411,7 +410,7 @@ def _build_response(self): event_dict = {} - event_dict["summary"] = escape(event.get("summary")) + event_dict["summary"] = event.get("summary") event_dict["location"] = event.get("location") event_dict["description"] = event.get("description") self.event_urls.append(