strophe / libstrophe

A simple, lightweight C library for writing XMPP clients
http://strophe.im/libstrophe
Other
401 stars 163 forks source link

Feature Request - expose _escape_xml to public (via fmt) #203

Closed matthias-hmb closed 2 years ago

matthias-hmb commented 2 years ago

The _escape_xml is used twice in the stanza code. It can also an important part for using xmpp_send_raw_string.

Request: would you adopt _escape_xml as part of the strophe_snprintf function, then it could be used that way. (bash, zsh, sqlite, ... use the additional %q format string for quoting)

Both times in the stanza.c it is first processed with xml escape and then snprintf and checked for mem error, so having the xml escape as part of the printf should work.

sjaeckel commented 2 years ago

The idea sounds very nice and I like it, but it has one major problem: we use standard printf() functions if they are available and recognized via the configure step.

There would indeed be an option when using the GNU C library to hook in custom printf format specifiers but all the other platforms would have to use either our printf() (which is thought as a fallback for weird platforms) or would require special handling in the code.

Also we're going to remove the xmpp_printf() functions from the public API soon, so you would have to rely on some internal API and that's not a good idea (from your position).

We're not striving to provide a good XMPP and a utility library, only the former one.

So I guess the easiest way for you would be to re-write the same functionality for your project or take our code and copy it to your project (and follow the license requirements of the library).

Or did I overlook some use-case?

I'm closing this now, but please feel free to re-open if you think we should re-evaluate.