Skip to content
Snippets Groups Projects
Commit 95c98a7a authored by deuce's avatar deuce
Browse files

Linting.

parent 4b95f64a
No related branches found
No related tags found
No related merge requests found
...@@ -17,6 +17,41 @@ var debug=true; ...@@ -17,6 +17,41 @@ var debug=true;
var debugRX=true; var debugRX=true;
/**********************/
/* Encoding functions */
/**********************/
/*
* These encode at least as is passed (token/string/binary)
*/
function encode_binary(str)
{
return '{'+str.length+'}\r\n'+str;
}
function encode_string(str)
{
if(str=='')
return('""');
if(str.search(/[\r\n\x80-\xff]/)==-1) {
str=str.replace(/[\\\"]/, "\\$1");
return '"'+str+'"';
}
return encode_binary(str);
}
function encode_token(str)
{
if(str=='')
return(encode_string(str));
if(str.search(/[\(\)\{ \x00-\x1F\*\%\"\\\]]/)==-1)
return str;
return(encode_string(str));
}
/*****************************/ /*****************************/
/* Message header extensions */ /* Message header extensions */
/*****************************/ /*****************************/
...@@ -37,7 +72,7 @@ MsgBase.HeaderPrototype.get_from=function (force) ...@@ -37,7 +72,7 @@ MsgBase.HeaderPrototype.get_from=function (force)
this.from_header = this.from+" <"+this.from.replace(/ /g,".").toLowerCase()+"@"+this.from_net_addr+">"; this.from_header = this.from+" <"+this.from.replace(/ /g,".").toLowerCase()+"@"+this.from_net_addr+">";
} }
return(this.from_header); return(this.from_header);
} };
MsgBase.HeaderPrototype.parse_headers=function(force) MsgBase.HeaderPrototype.parse_headers=function(force)
{ {
...@@ -47,11 +82,13 @@ MsgBase.HeaderPrototype.parse_headers=function(force) ...@@ -47,11 +82,13 @@ MsgBase.HeaderPrototype.parse_headers=function(force)
if(this.parsed_headers==undefined) if(this.parsed_headers==undefined)
this.parsed_headers=parse_headers(this.get_rfc822_header(force)) this.parsed_headers=parse_headers(this.get_rfc822_header(force))
return(this.parsed_headers); return(this.parsed_headers);
} };
MsgBase.HeaderPrototype.get_envelope=function (force) MsgBase.HeaderPrototype.get_envelope=function (force)
{ {
function parse_header(header, is_addresses) { function parse_header(header, is_addresses) {
var m2;
if(header==undefined || header.length==0) if(header==undefined || header.length==0)
return("NIL"); return("NIL");
...@@ -99,7 +136,7 @@ MsgBase.HeaderPrototype.get_envelope=function (force) ...@@ -99,7 +136,7 @@ MsgBase.HeaderPrototype.get_envelope=function (force)
envelope.push(parse_header(hdrs['message-id'], false)); envelope.push(parse_header(hdrs['message-id'], false));
} }
return(envelope); return(envelope);
} };
/***********************/ /***********************/
...@@ -144,41 +181,6 @@ function untagged(msg) ...@@ -144,41 +181,6 @@ function untagged(msg)
} }
/**********************/
/* Encoding functions */
/**********************/
/*
* These encode at least as is passed (token/string/binary)
*/
function encode_binary(str)
{
return '{'+str.length+'}\r\n'+str;
}
function encode_string(str)
{
if(str=='')
return('""');
if(str.search(/[\r\n\x80-\xff]/)==-1) {
str=str.replace(/[\\\"]/, "\\$1");
return '"'+str+'"';
}
return encode_binary(str);
}
function encode_token(str)
{
if(str=='')
return(encode_string(str));
if(str.search(/[\(\)\{ \x00-\x1F\*\%\"\\\]]/)==-1)
return str;
return(encode_string(str));
}
/*************************************************************/ /*************************************************************/
/* Fetch response generation... this is the tricky bit. :-) */ /* Fetch response generation... this is the tricky bit. :-) */
/*************************************************************/ /*************************************************************/
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment