dequote

Remove quotation marks V8.6 and later

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 ...

Get sendmail, 4th Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.