Skip to content
Open
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
28 changes: 14 additions & 14 deletions restalker/restalker.py
Original file line number Diff line number Diff line change
Expand Up @@ -774,9 +774,9 @@ def add_url_safely(url_str):
if cleaned_url:
urls.add(cleaned_url)
except (ValueError, AttributeError) as e:
print(f"[*] Error processing URL {url_str}: {e}")
print(f"[*] Error processing URL: value={url_str!r}, error={type(e).__name__}: {e}")
except Exception as e:
print(f"[*] Unexpected error with URL {url_str}: {e}")
print(f"[*] Unexpected error with URL: value={url_str!r}, error={type(e).__name__}: {e}")

# Process URLs found with regex
for url in re.findall(url_format, body, re.DOTALL):
Expand All @@ -802,16 +802,16 @@ def add_url_safely(url_str):

urls.add(UUF(full_url).rebuild())
except AttributeError:
print("[*] AttributeError: Invalid attribute in URL")
print(f"[*] AttributeError: Invalid attribute in URL, value={href!r}")
except ValueError:
print("[*] ValueError: Invalid URL format")
print(f"[*] ValueError: Invalid URL format, value={href!r}")
Comment on lines 803 to +807
Copy link

Copilot AI Feb 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this BeautifulSoup link loop, the exception handlers interpolate href (e.g., value={href!r}), but href is assigned inside the try. If an exception is raised before href is set (e.g., during url.get(...)), the handler will raise UnboundLocalError and mask the original failure. Initialize href = None before the try (or use a safer fallback like printing url/full_url via locals().get(...)).

Copilot uses AI. Check for mistakes.
except Exception as e:
print(f"Error parsing text with BeautifulSoup: {e}")
print(f"[*] Unexpected error: {e}")
print(f"Error parsing text with BeautifulSoup: value={href!r}, error={type(e).__name__}: {e}")
print(f"[*] Unexpected error: value={href!r}, error={type(e).__name__}: {e}")
Comment on lines +809 to +810
Copy link

Copilot AI Feb 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This exception path prints two separate lines for the same failure and uses a different prefix format than the other error messages. Consider consolidating to a single, consistently-formatted message to reduce noisy/duplicated output while preserving the new context fields.

Suggested change
print(f"Error parsing text with BeautifulSoup: value={href!r}, error={type(e).__name__}: {e}")
print(f"[*] Unexpected error: value={href!r}, error={type(e).__name__}: {e}")
print(f"[*] Unexpected error parsing text with BeautifulSoup: value={href!r}, error={type(e).__name__}: {e}")

Copilot uses AI. Check for mistakes.
except TypeError:
print("[*] TypeError: Invalid input type for BeautifulSoup")
print(f"[*] TypeError: Invalid input type for BeautifulSoup, value={body!r}")
except Exception as e:
print(f"[*] Error with HTML parsing: {e}")
print(f"[*] Error with HTML parsing: value={body!r}, error={type(e).__name__}: {e}")
Comment on lines +812 to +814
Copy link

Copilot AI Feb 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These error prints include value={body!r}. Since body is the full HTML/text chunk, this can be extremely large and may leak sensitive content into logs/stdout. Consider logging only type(body), len(body), and a truncated preview (or a hash) instead of the full repr.

Copilot uses AI. Check for mistakes.

for url in urls:
if url:
Expand Down Expand Up @@ -1018,7 +1018,7 @@ def _analyze_chunk(self, body, origin=None):
link = link.decode('utf-8')
link_item = UUF(link).full_url
except Exception as e:
print(f"[*] Error processing I2P URL: {e}")
print(f"[*] Error processing I2P URL: value={link!r}, error={type(e).__name__}: {e}")
link_item = link
yield I2P_URL(value=link_item)

Expand All @@ -1036,7 +1036,7 @@ def _analyze_chunk(self, body, origin=None):
link = link.decode('utf-8')
link_item = UUF(link).full_url
except Exception as e:
print(f"[*] Error processing Tor URL: {e}")
print(f"[*] Error processing Tor URL: value={link!r}, error={type(e).__name__}: {e}")
# If there's an error, just use the original link
if isinstance(link, bytes):
try:
Expand Down Expand Up @@ -1091,7 +1091,7 @@ def _analyze_chunk(self, body, origin=None):
link = link.decode('utf-8')
link_item = UUF(link).full_url
except Exception as e:
print(f"[*] Error processing WhatsApp URL: {e}")
print(f"[*] Error processing WhatsApp URL: value={link!r}, error={type(e).__name__}: {e}")
link_item = link
yield Whatsapp_URL(value=link_item)

Expand All @@ -1104,7 +1104,7 @@ def _analyze_chunk(self, body, origin=None):
link = link.decode('utf-8')
link_item = UUF(link).full_url
except Exception as e:
print(f"[*] Error processing Discord URL: {e}")
print(f"[*] Error processing Discord URL: value={link!r}, error={type(e).__name__}: {e}")
link_item = link
yield Discord_URL(value=link_item)

Expand All @@ -1117,7 +1117,7 @@ def _analyze_chunk(self, body, origin=None):
link = link.decode('utf-8')
link_item = UUF(link).full_url
except Exception as e:
print(f"[*] Error processing Telegram URL: {e}")
print(f"[*] Error processing Telegram URL: value={link!r}, error={type(e).__name__}: {e}")
link_item = link
yield Telegram_URL(value=link_item)

Expand All @@ -1129,7 +1129,7 @@ def _analyze_chunk(self, body, origin=None):
link = link.decode('utf-8')
link_item = UUF(link).full_url
except Exception as e:
print(f"[*] Error processing Skype URL: {e}")
print(f"[*] Error processing Skype URL: value={link!r}, error={type(e).__name__}: {e}")
link_item = link
yield Skype_URL(value=link_item)

Expand Down
Loading