RFC 1571 (rfc1571) - Page 2 of 4
Telnet Environment Option Interoperability Issues
Alternative Format: Original Text Document
RFC 1571 Environment Option Interoperability January 1994
3. Server Telnet: Parsing an IS or INFO
The IS or INFO in a suboption can only be legally followed by either
a VAR or a USERVAR. If an IS or INFO is immediately followed by a
VAR, then it can be assumed that the client has the correct
definitions for VAR and VALUE. If the IS or INFO is immediately
followed by a VALUE, then it can be assumed that the client has
reversed definitions for VAR and VALUE, and from that point on the
server should assume that the VALUE and VAR definitions are reversed.
If the IS or INFO is immediately followed by a USERVAR, further
hueristics must be applied to determine what are the client
definitions for VAR and VALUE. This is because it is legal for a
USERVAR to be followed by either a VAR or a VALUE. A VALUE after a
USERVAR gives the value for the USERVER. A VAR after a USERVAR
implies that the USERVAR is undefined.
The next thing to do is to scan the entire suboption, looking for two
consecutive instances of VAR or VALUE, or for a VAR or VALUE that is
empty. It is not legal for a suboption to contain two VALUEs without
an intervening VAR or USERVAR, and it is also not legal for a
suboption to contain an empty VAR. Thus, if two consecutive VARs or
an empty VALUE can be found, it can be assumed that the client that
generated the suboption uses the correct definitions for VAR and
VALUE. If two consecutive VALUEs or an empty VAR can be found, then
it can be assumed that the client that generated the suboption has
reversed definitions for VAR and VALUE, and from that point on the
server should assume that the VAR and VALUE definitions are reversed.
If things are still in doubt, the next test that can be applied is to
count up how many VARs, USERVARs and VALUEs were received.
(Consecutive USERVARs without an intervening VALUE or VAR should only
be counted as one.) Because a VALUE can only follow a VAR or a
USERVAR, there can never be more VALUEs than the sum of VARs and
USERVARs, and if all VARs and USERVARs have values, then there will
be exactly as many VALUEs as there are VARs and USERVARs. If the
number of VARs and USERVARs is the same as the total number of
VALUEs, then the client has correct definitions for VAR and VALUE.
If the number of VALUEs and USERVARs is the same as the total number
of VARs, then the client has reversed definitions for VAR and VALUE.
If the number of VALUEs is more than the sum of VARs and USERVARs, it
can be assumed that the client has reversed definitions of VAR and
VALUE, and if there are more VARs than USERVARs and VALUEs, then it
can be assumed that the client has the correct definitions for VAR
and VALUE. However, in order to get to this step, it has already
been determined that there are no consecutive VARs and VALUEs. A
little math will show that this means that the number of VALUEs will
Telnet Working Group