#!/usr/bin/env bash [ -f functions.sh ] && source functions.sh # Dependencies required by this trigger dependencies=("curl" "w3m" "sed") # Silently skip if dependencies are missing (triggers shouldn't error in channel) if ! check_dependencies "${dependencies[@]}" &> /dev/null; then exit 0 fi for l in $3 ; do text="${l#:}" if [[ "${text}" =~ http://|https://|www\..* ]]; then # Security: Only allow http:// and https:// protocols if [[ ! "$text" =~ ^https?:// ]]; then # Convert www. to http://www. if [[ "$text" =~ ^www\. ]]; then text="http://$text" else # Skip unknown protocols continue fi fi # Remove potentially dangerous shell metacharacters from URL text="${text//[;&|]/}" # Fetch page title with timeout and security limits pageTitle="$(curl -L -s --connect-timeout 5 --max-time 10 "$text" | sed -n -e 'H;${x;s!.*
]*>\(.*\).*!\1!;T;s!.*