home | O'Reilly's CD bookshelfs | FreeBSD | Linux | Cisco | Cisco Exam  


Previous Section Next Section

dequote

Remove quotation marks V8.6 and above

V8 sendmail can remove quotation marks from around tokens by using the special dequote database-map type. Because dequote is a type, not a database map, you need to declare it with a K configuration command before you can use it:

Kunquote dequote

This declares a database map named unquote of the type dequote. Once a database-map name has been declared, the dequote type can be used in the RHS of rules to remove quotation marks. It is used with $( and $), just like all database-map lookups:

$(unquote tokens $)

Here, arbitrary tokens are looked up in the database map named unquote. That database map is special because it is of the type dequote. Instead of being looked up in an external database file, tokens will just have any surrounding quotation marks removed:

"A.B.C"           becomes   A.B.C
"A"."B"."C"       becomes   A.B.C
"A B"             becomes   "A B"
"A,B"             becomes   "A,B"
"A>B"             becomes   "A>B"

The first example shows that surrounding quotation marks are removed. The second shows that multiple quoted tokens are all dequoted. The last three show that sendmail refuses to dequote any tokens that will form an illegal or ambiguous address when dequoted.

As an aid to understanding this dequoting process, run the following two-line configuration file in rule-testing mode:

V10
Kdequote dequote

You can then use the -bt /map command to try various dequoting possibilities:

> /map dequote "A.B.C"
map_lookup: dequote ("A.B.C") returns A.B.C (0)
> /map dequote "A"."B"."C"
map_lookup: dequote ("A"."B"."C") returns A.B.C (0)
> /map dequote "A B"
map_lookup: dequote ("A B") no match (0)

A few database switches are available to modify the behavior of this dequote database-map type. They are listed in Table 23-10.

Table 23-10. The dequote database-map type K command switches

Switch

§

Description

-a

-a

Append tag on successful match

-D

-D

Don't use this database map if DeliveryMode=defer

-S

-S

Space replacement character

-s

 

Synonym for -S

Note that beginning with V8.7, specifying the -s switch (and beginning with V8.10, specifying the -S switch) causes the space character to be replaced with another character before dequoting (-S):

Kdequote dequote -s+        V8.7 through V8.9
Kdequote dequote -S+        V8.10 and above

When using the mc configuration technique, dequote switches are declared like this:

define(`confDEQUOTE_OPTS', `-S+')

In either case, the last example would have the space converted to a plus before the conversion, thus resulting in a legal address. The "A B" example (which failed before) will become the following:

> /map dequote "A B"
map_lookup: dequote ("A B") returns A+B (0)

Also note that beginning with V8.8, specifying the -a switch causes a suffix of your choice to be appended to a successful match:

define(`confDEQUOTE_OPTS', `-a.yes')

In that case the "A.B.C" example would become the following:

> /map dequote "A.B.C"
map_lookup: dequote ("A.B.C") returns A.B.C.yes (0)

In addition to removing quotes, the dequote type also tokenizes everything that is returned. It does this because quotes are ordinarily used to mask the separation characters that delimit tokens.

No debugging switch is available to watch the actions of the dequote type.

    Previous Section Next Section