Overall I agree this is conceptually cleaner. Transforming between quoting formats is inherently delicate; I suspect there will always be at least one special case missed. I did find the dequoting code a bit baffling, but this is more of an implementation issue. There is a certain cognitive dissonance in using hex-quoting for tags and xapian-quoting for message-ids. Did you think about the implications of using xapian quoting for tags as well? d