Commit 3cd70850 authored by baire's avatar baire
Browse files

fixed FieldName to match the whitespaces in HCOLON correctly

parent 26667b1c
Loading
Loading
Loading
Loading
+12 −4
Original line number Diff line number Diff line
@@ -88,6 +88,9 @@ void read_sp (Buffer & buffer, Variable* v) {
#define SIPCHARS_ESCAPED	"(%[0-9A-F]{2})"
#define SIPCHARS_TOKEN "^[" SIPCHARS_ALFANUM ".!%*_+`'~\\-]+"

//FIXME: WSP is not clearly defined (all whitespaces) 
#define SIPCHARS_WSP		" 	"

// sip version
#define SIPCHARS_SIP_VERSION "SIP/[0-9].[0-9]"

@@ -96,6 +99,11 @@ void read_sp (Buffer & buffer, Variable* v) {
#define SIPCHARS_DOMAINLABEL	"[" SIPCHARS_ALFANUM "]([" SIPCHARS_ALFANUM "\\-]*[" SIPCHARS_ALFANUM "])?"
#define SIPCHARS_HOSTNAME	"(" SIPCHARS_DOMAINLABEL "\\.)*" SIPCHARS_TOPLABEL "\\.?"


#define SIPREG_LWS		"([" SIPCHARS_WSP "]*\r\n)?[" SIPCHARS_WSP "]+"
#define SIPREG_SWS		"(" SIPREG_LWS ")?"
#define SIPREG_HCOLON		"[ 	]*:" SIPREG_SWS

// IPv4
#define SIPCHARS_IP4	"([0-9]{1,3}\\.){3}[0-9]{1,3}"

@@ -367,7 +375,7 @@ void Method::Encode (Buffer& buffer) throw (EncodeError)
	const std::string & val = GetValueString();

	int i = 0;
	while (*(ppMethod[i]) && stricmp(ppMethod[i], val.c_str()) != 0)
	while (*(ppMethod[i]) && strcasecmp(ppMethod[i], val.c_str()) != 0)
		i++;

	if (*(ppMethod[i]) == 0) {
@@ -390,7 +398,7 @@ void Method::Decode (Buffer& buffer) throw (DecodeError)
	const std::string & val = reg_method.GetMatchedString();

	int i = 0;
	while (*(ppValue[i]) && stricmp(ppValue[i], val.c_str()) != 0)
	while (*(ppValue[i]) && strcasecmp(ppValue[i], val.c_str()) != 0)
		i++;

	if (*(ppValue[i]) == 0) {
@@ -583,13 +591,13 @@ void FieldName::Encode (Buffer& buffer) throw (EncodeError)
{
	Charstring c;

	c.SetValue ((SipHeaderMap::GetByIdFieldName(GetValueString()).mName + ':').c_str());
	c.SetValue ((SipHeaderMap::GetByIdFieldName(GetValueString()).mName + ": ").c_str());
	c.Encode(buffer);
}

void FieldName::Decode (Buffer& buffer) throw (DecodeError)
{
	static Regex reg_header_name ("^([A-Za-z\\-]+):", REG_ICASE);
	static Regex reg_header_name ("^([A-Z\\-]+)" SIPREG_HCOLON, REG_ICASE);

	reg_header_name.AssertMatch (buffer, this);
	SetValueString (SipHeaderMap::GetByName(reg_header_name.GetMatchedString (1)).mIdFieldName.c_str());