Skip to content

Commit

Permalink
Disabled dos2unix conversion for binary resources
Browse files Browse the repository at this point in the history
  • Loading branch information
veloman-yunkan committed Sep 11, 2024
1 parent 920d603 commit 425ae1e
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion scripts/kiwix-compile-resources
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,12 @@ resource_decl_template = """{namespaces_open}
extern const std::string {identifier};
{namespaces_close}"""

BINARY_RESOURCE_EXTENSIONS = ('.png', '.ttf', '.ico')

def is_binary_resource(filename):
_, extension = os.path.splitext(filename)
return extension in BINARY_RESOURCE_EXTENSIONS

class Resource:
def __init__(self, base_dirs, filename, cacheid=None):
filename = filename
Expand All @@ -71,7 +77,9 @@ class Resource:
for base_dir in base_dirs:
try:
with open(os.path.join(base_dir, filename), 'rb') as f:
self.data = f.read().replace(b"\r\n", b"\n")
self.data = f.read()
if not is_binary_resource(filename):
self.data = self.data.replace(b"\r\n", b"\n")
found = True
break
except FileNotFoundError:
Expand Down

0 comments on commit 425ae1e

Please sign in to comment.