I will agree that exhaustively defining text protocols is extremely hard, starting from character set / encoding and getting worse from there.
Typically you create message description which is then compiled to code that can serialize/deserialize messages in BER-TLV or PER-TLV.
I know because I wrote a complete parser/serializer for BER-TLV. It is simple protocol and any security issue is in the parser/serializer and not the protocol itself. That for simple reason that the protocol is nothing more than a format to serialize/deserialize the data.
BER-TLV is really nice protocol. I have worked with it for couple of years when I worked on an EMV application. It uses BER-TLV to communicate with the credit card but it is also very convenient format for all sorts of other uses and I would use it wherever I could. Think of it as Json but in binary form. It is not complicated and I would not even bother parsing the messages -- I could interpret hex dumps of them by sight very easily.
>>* a legal notice, here is a blessing:
>>*
>>* May you do good and not evil.
>>* May you find forgiveness for yourself and forgive others.
>>* May you share freely, never taking more than you give.
Above all, this note at the beginning of the source code impressed me.
I don't disagree in principle but I've come across a handful of very poorly documentated binary protocols in my years and that is an extremely painful thing to deal with compared to text-based protocols.
GET /asdfasdfasdfdsaf
X-Asdf-Asdf: 83e7234
HTTP/1.0 202
X-83e7233: 1
X-83f730b: 4
It's text, but you still have no idea what's going on.Overall, I think it's kind of a wash. It's basically equally easy to take a documented text or binary protocol and write a working parser. Neither format solves any intrinsic problems -- malicious input has to be accounted for, you have to write fuzz tests, you have to deal with broken producers. It's a wash.
People like text because they can type it into telnet and see something work, which is kind of cool, but probably not a productive use of time. I can type HTTP messages, but use curl anyway. (SMTP was always my favorite. "HELO there / MAIL FROM foo / RCPT TO bar / email body / ." Felt like a real conversation going on. Still not sure how to send an email that consists of a single dot on its own line though.)
It seems you prefix any line of data starting with a period with an additional period, to therefore distinguish it from the end of mail period.
A line starting with a period is escaped by adding an extra period; the receiving side removes the first character of a line if it is a period.
Except I did something like this once in the past (but with zero byte instead of dot).
However, HTTP/2 and HTTP/3 certainly are, though the reasons why they are complicated have nothing to do with choosing to use a binary based format. (They are complicated for good reason, though, and I hope that browsers and servers can continue to support HTTP/1 as the baseline till the sun burns out, just to make life easier.)
Nobody does that anymore and debugging is easily solved by converting your binary protocol to a textual form.
* https://en.wikipedia.org/wiki/History_of_email
Perusing document-based information was also done via clients, first with Gopher and then with the WWW: either GUIs like Mosaic, or on the CLI via (e.g.) Lynx.
well, other side of HTTP was telnet in the terminal - this is why it is ASCII to begin with
https://en.wikipedia.org/wiki/Line_Mode_Browser
But that didn't just spit out the HTTP response - it parsed and rendered the HTML.
Text protocols have difficult problems like escaping or detecting the end of particular field that are frequent source of mistakes.
The issue is that many (especially scripting) languages treat binary data as second class.
The only real issue is that inspecting the binary message visually is little bit more difficult. You can usually easily tell if your data structure is broken if it is in text form. What I do is I usually have some simple converter that converts the binary message to text form and this helps me inspect the message easily.