Add warning if post content contains only a single web link#

main
Bob Mottram 2025-09-22 11:52:46 +01:00
parent c5cb92f371
commit cc922c0ed3
30 changed files with 75 additions and 28 deletions

View File

@ -10,6 +10,7 @@ __module_group__ = "Core"
import os import os
from utils import load_json from utils import load_json
from utils import get_content_from_post from utils import get_content_from_post
from utils import content_is_single_url
def load_cw_lists(base_dir: str, verbose: bool) -> {}: def load_cw_lists(base_dir: str, verbose: bool) -> {}:
@ -124,6 +125,15 @@ def add_cw_from_lists(post_json_object: {}, cw_lists: {}, translate: {},
if not content: if not content:
return return
# warn about possible dangerous web links, which could be phishing scams
if content_is_single_url(content):
single_link_warning = translate['Warning: Possible dangerous link']
if cw_text:
if single_link_warning not in cw_text:
cw_text = single_link_warning + ' / ' + cw_text
else:
cw_text = single_link_warning
post_tags: list[dict] = [] post_tags: list[dict] = []
if post_json_object['object'].get('tag'): if post_json_object['object'].get('tag'):
if isinstance(post_json_object['object']['tag'], list): if isinstance(post_json_object['object']['tag'], list):

View File

@ -761,5 +761,6 @@
"SPORTS": "الرياضة", "SPORTS": "الرياضة",
"THEATRE": "مسرح", "THEATRE": "مسرح",
"WORKSHOPS_SKILL_SHARING": "ورش العمل / مشاركة المهارات", "WORKSHOPS_SKILL_SHARING": "ورش العمل / مشاركة المهارات",
"Status": "حالة" "Status": "حالة",
"Warning: Possible dangerous link": "تحذير: رابط خطير محتمل"
} }

View File

@ -761,5 +761,6 @@
"SPORTS": "খেলাধুলা", "SPORTS": "খেলাধুলা",
"THEATRE": "থিয়া", "THEATRE": "থিয়া",
"WORKSHOPS_SKILL_SHARING": "কর্মশালা / দক্ষতা ভাগ করে নেওয়া", "WORKSHOPS_SKILL_SHARING": "কর্মশালা / দক্ষতা ভাগ করে নেওয়া",
"Status": "অবস্থা" "Status": "অবস্থা",
"Warning: Possible dangerous link": "সতর্কতা: সম্ভাব্য বিপজ্জনক লিঙ্ক"
} }

View File

@ -761,5 +761,6 @@
"SPORTS": "Esport", "SPORTS": "Esport",
"THEATRE": "Teat", "THEATRE": "Teat",
"WORKSHOPS_SKILL_SHARING": "Tallers / compartició dhabilitats", "WORKSHOPS_SKILL_SHARING": "Tallers / compartició dhabilitats",
"Status": "Estat" "Status": "Estat",
"Warning: Possible dangerous link": "Avís: Possible enllaç perillós"
} }

View File

@ -761,5 +761,6 @@
"SPORTS": "Chwaraeon", "SPORTS": "Chwaraeon",
"THEATRE": "Theatr", "THEATRE": "Theatr",
"WORKSHOPS_SKILL_SHARING": "Gweithdai / Rhannu Sgiliau", "WORKSHOPS_SKILL_SHARING": "Gweithdai / Rhannu Sgiliau",
"Status": "Statws" "Status": "Statws",
"Warning: Possible dangerous link": "Rhybudd: Cyswllt peryglus posibl"
} }

View File

@ -761,5 +761,6 @@
"SPORTS": "Sport", "SPORTS": "Sport",
"THEATRE": "Theater", "THEATRE": "Theater",
"WORKSHOPS_SKILL_SHARING": "Workshops / Fertigkeitsaustausch", "WORKSHOPS_SKILL_SHARING": "Workshops / Fertigkeitsaustausch",
"Status": "Status" "Status": "Status",
"Warning: Possible dangerous link": "Warnung: Möglicher gefährlicher Link"
} }

View File

@ -761,5 +761,6 @@
"SPORTS": "Αθλητισμός", "SPORTS": "Αθλητισμός",
"THEATRE": "Θέατρο", "THEATRE": "Θέατρο",
"WORKSHOPS_SKILL_SHARING": "Εργαστήρια / κοινή χρήση δεξιοτήτων", "WORKSHOPS_SKILL_SHARING": "Εργαστήρια / κοινή χρήση δεξιοτήτων",
"Status": "Κατάσταση" "Status": "Κατάσταση",
"Warning: Possible dangerous link": "Προειδοποίηση: Πιθανός επικίνδυνος σύνδεσμος"
} }

View File

@ -761,5 +761,6 @@
"SPORTS": "Sports", "SPORTS": "Sports",
"THEATRE": "Theatre", "THEATRE": "Theatre",
"WORKSHOPS_SKILL_SHARING": "Workshops / Skill sharing", "WORKSHOPS_SKILL_SHARING": "Workshops / Skill sharing",
"Status": "Status" "Status": "Status",
"Warning: Possible dangerous link": "Warning: Possible dangerous link"
} }

View File

@ -761,5 +761,6 @@
"SPORTS": "Deportes", "SPORTS": "Deportes",
"THEATRE": "Teatro", "THEATRE": "Teatro",
"WORKSHOPS_SKILL_SHARING": "Talleres / Experiencia de habilidades", "WORKSHOPS_SKILL_SHARING": "Talleres / Experiencia de habilidades",
"Status": "Estado" "Status": "Estado",
"Warning: Possible dangerous link": "Advertencia: Posible enlace peligroso"
} }

View File

@ -761,5 +761,6 @@
"SPORTS": "ورزش", "SPORTS": "ورزش",
"THEATRE": "تئاتر", "THEATRE": "تئاتر",
"WORKSHOPS_SKILL_SHARING": "کارگاه ها / اشتراک مهارت", "WORKSHOPS_SKILL_SHARING": "کارگاه ها / اشتراک مهارت",
"Status": "وضعیت" "Status": "وضعیت",
"Warning: Possible dangerous link": "هشدار: احتمال لینک خطرناک"
} }

View File

@ -761,5 +761,6 @@
"SPORTS": "Urheilu", "SPORTS": "Urheilu",
"THEATRE": "Teatteri", "THEATRE": "Teatteri",
"WORKSHOPS_SKILL_SHARING": "Työpajat / taitojen jakaminen", "WORKSHOPS_SKILL_SHARING": "Työpajat / taitojen jakaminen",
"Status": "Status" "Status": "Status",
"Warning: Possible dangerous link": "Varoitus: Mahdollisesti vaarallinen linkki"
} }

View File

@ -761,5 +761,6 @@
"SPORTS": "Sportive", "SPORTS": "Sportive",
"THEATRE": "Théâtre", "THEATRE": "Théâtre",
"WORKSHOPS_SKILL_SHARING": "Ateliers / partage des compétences", "WORKSHOPS_SKILL_SHARING": "Ateliers / partage des compétences",
"Status": "Statut" "Status": "Statut",
"Warning: Possible dangerous link": "Avertissement : lien potentiellement dangereux"
} }

View File

@ -761,5 +761,6 @@
"SPORTS": "Oll naordaí", "SPORTS": "Oll naordaí",
"THEATRE": "Tochadán", "THEATRE": "Tochadán",
"WORKSHOPS_SKILL_SHARING": "Ceardlanna / comhroinnt scileanna", "WORKSHOPS_SKILL_SHARING": "Ceardlanna / comhroinnt scileanna",
"Status": "Stádas" "Status": "Stádas",
"Warning: Possible dangerous link": "Rabhadh: Nasc contúirteach féideartha"
} }

View File

@ -761,5 +761,6 @@
"SPORTS": "ספו", "SPORTS": "ספו",
"THEATRE": "תֵאַטרוֹן", "THEATRE": "תֵאַטרוֹן",
"WORKSHOPS_SKILL_SHARING": "סדנאות / שיתוף מיומנות", "WORKSHOPS_SKILL_SHARING": "סדנאות / שיתוף מיומנות",
"Status": "סטָטוּס" "Status": "סטָטוּס",
"Warning: Possible dangerous link": "אזהרה: קישור מסוכן אפשרי"
} }

View File

@ -761,5 +761,6 @@
"SPORTS": "खेल", "SPORTS": "खेल",
"THEATRE": "थिएटर", "THEATRE": "थिएटर",
"WORKSHOPS_SKILL_SHARING": "कार्यशालाएं / कौशल साझाकरण", "WORKSHOPS_SKILL_SHARING": "कार्यशालाएं / कौशल साझाकरण",
"Status": "स्थिति" "Status": "स्थिति",
"Warning: Possible dangerous link": "चेतावनी: संभावित खतरनाक लिंक"
} }

View File

@ -761,5 +761,6 @@
"SPORTS": "Sport", "SPORTS": "Sport",
"THEATRE": "Teatro", "THEATRE": "Teatro",
"WORKSHOPS_SKILL_SHARING": "Seminari / condivisione delle competenze", "WORKSHOPS_SKILL_SHARING": "Seminari / condivisione delle competenze",
"Status": "Stato" "Status": "Stato",
"Warning: Possible dangerous link": "Attenzione: possibile collegamento pericoloso"
} }

View File

@ -761,5 +761,6 @@
"SPORTS": "スポーツ", "SPORTS": "スポーツ",
"THEATRE": "劇場", "THEATRE": "劇場",
"WORKSHOPS_SKILL_SHARING": "ワークショップ /スキル共有", "WORKSHOPS_SKILL_SHARING": "ワークショップ /スキル共有",
"Status": "状態" "Status": "状態",
"Warning: Possible dangerous link": "警告: 危険なリンクの可能性があります"
} }

View File

@ -761,5 +761,6 @@
"SPORTS": "스포츠", "SPORTS": "스포츠",
"THEATRE": "극장", "THEATRE": "극장",
"WORKSHOPS_SKILL_SHARING": "워크샵 / 기술 공유", "WORKSHOPS_SKILL_SHARING": "워크샵 / 기술 공유",
"Status": "상태" "Status": "상태",
"Warning: Possible dangerous link": "경고: 위험한 링크가 있을 수 있습니다"
} }

View File

@ -761,5 +761,6 @@
"SPORTS": "Beden", "SPORTS": "Beden",
"THEATRE": "Şano", "THEATRE": "Şano",
"WORKSHOPS_SKILL_SHARING": "Karker / Parvekirina Skill", "WORKSHOPS_SKILL_SHARING": "Karker / Parvekirina Skill",
"Status": "Cî" "Status": "Cî",
"Warning: Possible dangerous link": "Hişyarî: Girêdaneke gengaz a xeternak"
} }

View File

@ -761,5 +761,6 @@
"SPORTS": "Sport", "SPORTS": "Sport",
"THEATRE": "Theater", "THEATRE": "Theater",
"WORKSHOPS_SKILL_SHARING": "Workshops / vaardigheden delen", "WORKSHOPS_SKILL_SHARING": "Workshops / vaardigheden delen",
"Status": "Status" "Status": "Status",
"Warning: Possible dangerous link": "Waarschuwing: Mogelijk gevaarlijke link"
} }

View File

@ -757,5 +757,6 @@
"SPORTS": "Sports", "SPORTS": "Sports",
"THEATRE": "Theatre", "THEATRE": "Theatre",
"WORKSHOPS_SKILL_SHARING": "Workshops / Skill sharing", "WORKSHOPS_SKILL_SHARING": "Workshops / Skill sharing",
"Status": "Status" "Status": "Status",
"Warning: Possible dangerous link": "Warning: Possible dangerous link"
} }

View File

@ -761,5 +761,6 @@
"SPORTS": "Lekkoatletyka", "SPORTS": "Lekkoatletyka",
"THEATRE": "Teatr", "THEATRE": "Teatr",
"WORKSHOPS_SKILL_SHARING": "Warsztaty / udostępnianie umiejętności", "WORKSHOPS_SKILL_SHARING": "Warsztaty / udostępnianie umiejętności",
"Status": "Status" "Status": "Status",
"Warning: Possible dangerous link": "Ostrzeżenie: Możliwe niebezpieczne łącze"
} }

View File

@ -761,5 +761,6 @@
"SPORTS": "Esportes", "SPORTS": "Esportes",
"THEATRE": "Teatro", "THEATRE": "Teatro",
"WORKSHOPS_SKILL_SHARING": "Workshops / compartilhamento de habilidades", "WORKSHOPS_SKILL_SHARING": "Workshops / compartilhamento de habilidades",
"Status": "Estatuto" "Status": "Estatuto",
"Warning: Possible dangerous link": "Aviso: possível ligação perigosa"
} }

View File

@ -761,5 +761,6 @@
"SPORTS": "Спорт", "SPORTS": "Спорт",
"THEATRE": "Театр", "THEATRE": "Театр",
"WORKSHOPS_SKILL_SHARING": "Семинары / обмен навыками", "WORKSHOPS_SKILL_SHARING": "Семинары / обмен навыками",
"Status": "Статус" "Status": "Статус",
"Warning: Possible dangerous link": "Внимание: возможная опасная ссылка"
} }

View File

@ -761,5 +761,6 @@
"SPORTS": "Michezo", "SPORTS": "Michezo",
"THEATRE": "Ukumbi wa michezo", "THEATRE": "Ukumbi wa michezo",
"WORKSHOPS_SKILL_SHARING": "Warsha / Kushiriki kwa Ustadi", "WORKSHOPS_SKILL_SHARING": "Warsha / Kushiriki kwa Ustadi",
"Status": "Hali" "Status": "Hali",
"Warning: Possible dangerous link": "Onyo: Kiungo hatari kinachowezekana"
} }

View File

@ -761,5 +761,6 @@
"SPORTS": "Spor", "SPORTS": "Spor",
"THEATRE": "Tiyatro", "THEATRE": "Tiyatro",
"WORKSHOPS_SKILL_SHARING": "Çalıştaylar / Beceri Paylaşımı", "WORKSHOPS_SKILL_SHARING": "Çalıştaylar / Beceri Paylaşımı",
"Status": "Durum" "Status": "Durum",
"Warning: Possible dangerous link": "Uyarı: Olası tehlikeli bağlantı"
} }

View File

@ -761,5 +761,6 @@
"SPORTS": "Спорт", "SPORTS": "Спорт",
"THEATRE": "Театр", "THEATRE": "Театр",
"WORKSHOPS_SKILL_SHARING": "Семінари / обмін навичками", "WORKSHOPS_SKILL_SHARING": "Семінари / обмін навичками",
"Status": "Статус" "Status": "Статус",
"Warning: Possible dangerous link": "Попередження: Можливе небезпечне посилання"
} }

View File

@ -761,5 +761,6 @@
"SPORTS": "ספּאָרט", "SPORTS": "ספּאָרט",
"THEATRE": "טעאַטער", "THEATRE": "טעאַטער",
"WORKSHOPS_SKILL_SHARING": "וואָרקשאָפּ / סקילז ייַנטיילונג", "WORKSHOPS_SKILL_SHARING": "וואָרקשאָפּ / סקילז ייַנטיילונג",
"Status": "סטאַטוס" "Status": "סטאַטוס",
"Warning: Possible dangerous link": "ווארענונג: מעגלעכער געפערלעכער פארבינדונג"
} }

View File

@ -761,5 +761,6 @@
"SPORTS": "运动的", "SPORTS": "运动的",
"THEATRE": "剧院", "THEATRE": "剧院",
"WORKSHOPS_SKILL_SHARING": "研讨会 /技能共享", "WORKSHOPS_SKILL_SHARING": "研讨会 /技能共享",
"Status": "地位" "Status": "地位",
"Warning: Possible dangerous link": "警告:可能存在危险链接"
} }

View File

@ -668,6 +668,15 @@ def remove_html(content: str) -> str:
return result return result
def content_is_single_url(content: str) -> bool:
"""Returns true of the content string only contains a web link
"""
if '<a href=' in content:
if not remove_html(content).strip():
return True
return False
def remove_style_within_html(content: str) -> str: def remove_style_within_html(content: str) -> str:
"""Removes style="something" within html post content. """Removes style="something" within html post content.
Used to ensure that styles Used to ensure that styles