Skip to content

Commit

Permalink
formatter: add escape command to escape html
Browse files Browse the repository at this point in the history
* google_calendar module: let users decide if they want to escape or not
  • Loading branch information
ultrabug authored Oct 2, 2022
1 parent 47a8469 commit c18212f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 3 additions & 0 deletions py3status/formatter.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import re
from html import escape
from math import ceil
from numbers import Number
from urllib.parse import parse_qsl
Expand Down Expand Up @@ -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:
Expand Down
3 changes: 1 addition & 2 deletions py3status/modules/google_calendar.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,6 @@
import datetime
import time
from pathlib import Path
from html import escape

try:
from googleapiclient import discovery
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit c18212f

Please sign in to comment.