Skip to content

Commit

Permalink
Convert bytes to str in fix_text
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanw committed Nov 19, 2024
1 parent 3e7a8cc commit b166ab3
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/filingcabinet/pdf_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import subprocess
import tempfile
from pathlib import Path
from typing import BinaryIO, Union
from typing import BinaryIO, Optional, Union

import pikepdf
import wand
Expand Down Expand Up @@ -175,9 +175,11 @@ def get_markdown_outline(self):
return "".join(self.iter_markdown_outline())


def fix_text(text):
def fix_text(text: Optional[str | bytes]) -> Optional[str]:
if text is None:
return None
if isinstance(text, bytes):
text = text.decode("utf-8", errors="ignore")
return text.replace("\u0000", "")


Expand Down

0 comments on commit b166ab3

Please sign in to comment.