~ubuntu-branches/debian/stretch/alpine/stretch

« back to all changes in this revision

Viewing changes to web/cgi/alpine/2.0/conduit/expand.tcl

  • Committer: Package Import Robot
  • Author(s): Asheesh Laroia
  • Date: 2013-05-19 16:15:01 UTC
  • mfrom: (1.1.10)
  • Revision ID: package-import@ubuntu.com-20130519161501-epf6pfldn07xnd11
Tags: 2.10+dfsg-1
* New upstream release.
* This release ships a fix for an issue where the PREFDATETIME token
  was always set to "Sun" incorrectly. (Closes: #692870)
* This release ships a fix for IMAP-encoded non-ASCII folder names.
  (Closes: #674067)
* This release simplifies (and corrects) S/MIME handling for messages
  that encrypted *and* signed. (Closes: #653420)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!./tclsh
 
2
# $Id: expand.tcl 1266 2009-07-14 18:39:12Z hubert@u.washington.edu $
 
3
# ========================================================================
 
4
# Copyright 2008 University of Washington
 
5
#
 
6
# Licensed under the Apache License, Version 2.0 (the "License");
 
7
# you may not use this file except in compliance with the License.
 
8
# You may obtain a copy of the License at
 
9
#
 
10
#     http://www.apache.org/licenses/LICENSE-2.0
 
11
#
 
12
# ========================================================================
 
13
 
 
14
#  expand.tcl
 
15
#
 
16
#  Purpose:  CGI script to supply data to composer
 
17
#
 
18
#  Input:
 
19
#            along with possible search parameters:
 
20
set expand_args {
 
21
  {book         {}      -1}
 
22
  {index        {}      -1}
 
23
  {addrs                {}      ""}
 
24
}
 
25
 
 
26
# inherit global config
 
27
source ../alpine.tcl
 
28
 
 
29
# Import data validate it and get session id
 
30
if {[catch {WPGetInputAndID sessid} result]} {
 
31
  error "expand.tcl: $result"
 
32
}
 
33
 
 
34
# grok parameters
 
35
foreach item $expand_args {
 
36
  if {[catch {eval WPImport $item} result]} {
 
37
    error "expand.tcl: $result"
 
38
  }
 
39
}
 
40
 
 
41
catch (unset errstr}
 
42
set errlist {}
 
43
set expaddr {}
 
44
 
 
45
if {[regexp {^[0-9]*$} $book] && [regexp {^[0-9,]*$} $index]} {
 
46
  foreach i [split $index ","] {
 
47
    if {[catch {WPCmd PEAddress entry $book "" $i} entry]} {
 
48
      lappend errlist $entry
 
49
    } else {
 
50
      regsub -all "'" [lindex $entry 0] "\\'" resaddr
 
51
      lappend expaddr $resaddr
 
52
      set fcc ""
 
53
    }
 
54
  }
 
55
} elseif {[string length $addrs]} {
 
56
  if {[catch {WPCmd PEAddress expand $addrs [lindex [WPCmd PECompose fccdefault] 1]} result]} {
 
57
    set errstr $result
 
58
  } else {
 
59
    set expaddr [list [lindex $result 0]]
 
60
    set fcc [lindex $result 2]
 
61
  }
 
62
} else {
 
63
  set errstr "Unknown expand options"
 
64
}
 
65
 
 
66
puts stdout "Content-type: text/xml; charset=\"UTF-8\"\n"
 
67
puts stdout {<?xml version="1.0" encoding="UTF-8"?>}
 
68
 
 
69
if {[info exists errstr] && [string length $errstr]} {
 
70
  puts stdout "<ResultSet totalResultsAvailable=\"1\"><Result>"
 
71
  puts stdout "<Error>$errstr</Error>"
 
72
  puts stdout "</Result></ResultSet>"
 
73
} else {
 
74
  puts stdout "<ResultSet totalResultsAvailable=\"[expr {[llength $expaddr] + [llength $errlist]}]\">"
 
75
  foreach e $errlist {
 
76
    puts stdout "<Result><Error>[cgi_quote_html $e]</Error></Result>"
 
77
  }
 
78
 
 
79
  foreach a $expaddr {
 
80
    puts stdout "<Result><Address>[cgi_quote_html $a]</Address><Fcc>[cgi_quote_html $fcc]</Fcc></Result>"
 
81
  }
 
82
 
 
83
  puts stdout "</ResultSet>"
 
84
}