Please see attached a small patch to document why some text-processing functions are marked as leakproof, while some others are not.
This is more or less a verbatim copy of Tom's comment in email thread at [1].
I could not find an appropriate spot to place these comments, so I placed them on bttextcmp() function, The only other place that I could see we can place these comments is in the file src/backend/optimizer/README, because there is some consideration given to leakproof functions in optimizer docs. But these comments seem quite out of place in optimizer docs.