diff --git a/bin/view-email-html b/bin/view-email-html index a49462b..a99f2ad 100755 --- a/bin/view-email-html +++ b/bin/view-email-html @@ -54,11 +54,32 @@ else echo ".toggle { position: fixed; top: 20px; right: 20px; width: 44px; height: 44px; border: 1px solid var(--border); border-radius: 50%; cursor: pointer; background: var(--header-bg); color: var(--text); font-size: 20px; transition: all 0.2s; box-shadow: 0 2px 8px var(--shadow); }" echo ".toggle:hover { transform: scale(1.05); box-shadow: 0 4px 12px var(--shadow); }" echo ".sun { display: none; } .dark .sun { display: inline; } .dark .moon { display: none; }" + echo ".attachments { margin-top: 25px; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }" + echo ".attachments-header { padding: 12px 20px; background: var(--header-bg); cursor: pointer; font-weight: 500; color: var(--muted); }" + echo ".attachments-header:hover { background: var(--border); }" + echo ".attachments-content { display: none; padding: 15px; background: var(--bg); }" + echo ".attachments-content.show { display: flex; flex-wrap: wrap; gap: 15px; }" + echo ".attachment { background: var(--header-bg); border-radius: 8px; padding: 10px; text-align: center; min-width: 120px; border: 1px solid var(--border); }" + echo ".attachment img { max-width: 200px; max-height: 150px; object-fit: contain; margin: 0; }" + echo ".attachment-name { margin: 8px 0 0; font-size: 0.85em; color: var(--muted); word-break: break-all; }" + echo ".attachment-icon { font-size: 2em; display: block; margin-bottom: 5px; }" + echo ".attachment img { cursor: pointer; transition: transform 0.2s; }" + echo ".attachment img:hover { transform: scale(1.05); }" + echo ".lightbox { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.9); z-index: 1000; justify-content: center; align-items: center; cursor: zoom-out; }" + echo ".lightbox.show { display: flex; }" + echo ".lightbox img { max-width: 95%; max-height: 95%; object-fit: contain; border-radius: 8px; box-shadow: 0 4px 30px rgba(0,0,0,0.5); }" + echo ".lightbox-close { position: fixed; top: 20px; right: 20px; color: white; font-size: 30px; cursor: pointer; background: rgba(0,0,0,0.5); width: 44px; height: 44px; border-radius: 50%; display: flex; align-items: center; justify-content: center; }" + echo ".lightbox-close:hover { background: rgba(0,0,0,0.8); }" echo "" + echo '' echo '' echo "" # Extract and display headers (handles multi-line headers) @@ -240,6 +261,20 @@ else sub(/[.,;:!?)]+$/, "", url) result = before "" url "" after } + # Sixth: Handle [cid:image] inline images + while (match(result, /\[cid:[^\]]+\]/)) { + before = substr(result, 1, RSTART-1) + # Extract image name from cid reference + cid = substr(result, RSTART+5, RLENGTH-6) + after = substr(result, RSTART+RLENGTH) + # Extract just the filename part (before @) + if (match(cid, /@/)) { + imgname = substr(cid, 1, RSTART-1) + } else { + imgname = cid + } + result = before "\""" after + } return result } { @@ -267,10 +302,28 @@ else ' echo "" - # Show extracted images - find "$tmpdir" -maxdepth 1 -type f \( -iname "*.png" -o -iname "*.jpg" -o -iname "*.jpeg" -o -iname "*.gif" \) 2>/dev/null | while read -r img; do - echo "

" - done + # Show attachments in collapsible section + attachments=$(find "$tmpdir" -maxdepth 1 -type f \( -iname "*.png" -o -iname "*.jpg" -o -iname "*.jpeg" -o -iname "*.gif" -o -iname "*.pdf" -o -iname "*.doc*" -o -iname "*.xls*" -o -iname "*.zip" -o -iname "*.tar*" \) 2>/dev/null) + if [[ -n $attachments ]]; then + count=$(echo "$attachments" | wc -l | tr -d ' ') + echo '
' + echo "
▶ Attachments ($count)
" + echo '
' + echo "$attachments" | while read -r file; do + basename=$(basename "$file") + ext="${basename##*.}" + ext_lower=$(echo "$ext" | tr '[:upper:]' '[:lower:]') + case "$ext_lower" in + png | jpg | jpeg | gif) + echo "
\"$basename\"

$basename

" + ;; + *) + echo "
📎

$basename

" + ;; + esac + done + echo "
" + fi echo "" } >"$tmpfile"