Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open link-verifier target files with encoding="utf8", errors='ignore' options #29

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion link-verifier/verify-links.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,11 @@ def main():
dirs[:] = [dir for dir in dirs if dir.lower() not in exclude_dirs]
for file in files:
if any(file.endswith(file_type) for file_type in args.include_files):
with open(os.path.join(root, file), 'r') as f:
f_path = os.path.join(root, file)
print("Processing File: {}".format(f_path))
with open(f_path, 'r', encoding="utf8", errors='ignore') as f:
paulbartell marked this conversation as resolved.
Show resolved Hide resolved
# errors='ignore' argument Suppresses UnicodeDecodeError
# when reading invalid UTF-8 characters.
text = f.read()
urls = re.findall(URL_SEARCH_TERM, text)
for url in urls:
Expand Down