Skip to content

Commit

Permalink
fix artist and song name with special character
Browse files Browse the repository at this point in the history
  • Loading branch information
kittinan committed Nov 3, 2024
1 parent a83db2b commit 30e66b8
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions api/view.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import functools
import colorgram
import math
import html

ImageFile.LOAD_TRUNCATED_IMAGES = True

Expand Down Expand Up @@ -48,6 +49,7 @@ def generate_css_bar(num_bar=75):

@functools.lru_cache(maxsize=128)
def load_image(url):
print("load image:", url)
resposne = requests.get(url)
return resposne.content

Expand All @@ -70,6 +72,10 @@ def isLightOrDark(rgbColor=[0, 128, 255], threshold=127.5):
return "dark"


def encode_html_entities(text):
return html.escape(text)


# @functools.lru_cache(maxsize=128)
def make_svg(
artist_name,
Expand All @@ -85,6 +91,10 @@ def make_svg(
height = 0
num_bar = 75

# Sanitize input
artist_name = encode_html_entities(artist_name)
song_name = encode_html_entities(song_name)

if theme == "compact":
if cover_image:
height = 400
Expand Down

0 comments on commit 30e66b8

Please sign in to comment.