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
from utils import load_json
from utils import get_content_from_post
from utils import content_is_single_url
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:
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] = []
if post_json_object['object'].get('tag'):
if isinstance(post_json_object['object']['tag'], list):

View File

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

View File

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

View File

@ -761,5 +761,6 @@
"SPORTS": "Esport",
"THEATRE": "Teat",
"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",
"THEATRE": "Theatr",
"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",
"THEATRE": "Theater",
"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": "Αθλητισμός",
"THEATRE": "Θέατρο",
"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"
"Status": "Status",
"Warning: Possible dangerous link": "Warning: Possible dangerous link"
}

View File

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

View File

@ -761,5 +761,6 @@
"SPORTS": "Urheilu",
"THEATRE": "Teatteri",
"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",
"THEATRE": "Théâtre",
"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í",
"THEATRE": "Tochadán",
"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": "ספו",
"THEATRE": "תֵאַטרוֹן",
"WORKSHOPS_SKILL_SHARING": "סדנאות / שיתוף מיומנות",
"Status": "סטָטוּס"
"Status": "סטָטוּס",
"Warning: Possible dangerous link": "אזהרה: קישור מסוכן אפשרי"
}

View File

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

View File

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

View File

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

View File

@ -761,5 +761,6 @@
"SPORTS": "Beden",
"THEATRE": "Şano",
"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",
"THEATRE": "Theater",
"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",
"THEATRE": "Theatre",
"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",
"THEATRE": "Teatr",
"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",
"THEATRE": "Teatro",
"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": "Спорт",
"THEATRE": "Театр",
"WORKSHOPS_SKILL_SHARING": "Семинары / обмен навыками",
"Status": "Статус"
"Status": "Статус",
"Warning: Possible dangerous link": "Внимание: возможная опасная ссылка"
}

View File

@ -761,5 +761,6 @@
"SPORTS": "Michezo",
"THEATRE": "Ukumbi wa michezo",
"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",
"THEATRE": "Tiyatro",
"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": "Спорт",
"THEATRE": "Театр",
"WORKSHOPS_SKILL_SHARING": "Семінари / обмін навичками",
"Status": "Статус"
"Status": "Статус",
"Warning: Possible dangerous link": "Попередження: Можливе небезпечне посилання"
}

View File

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

View File

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

View File

@ -668,6 +668,15 @@ def remove_html(content: str) -> str:
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:
"""Removes style="something" within html post content.
Used to ensure that styles