Loading codec/c++/codec.h +3 −0 Original line number Diff line number Diff line Loading @@ -58,6 +58,9 @@ public: void Decode (Buffer& buffer) throw (DecodeError); }; // additional attributes #define DEFINITIONS_Addr_Union() int mPosition; }} //namespaces #endif // ----- #ifndef CODEC_INC ----- Loading codec/c++/sip_codets.cpp +37 −0 Original line number Diff line number Diff line Loading @@ -1186,6 +1186,9 @@ void FieldName::Decode (Buffer& buffer) throw (DecodeError) void Addr_Union::PreDecode (Buffer& buffer) throw (DecodeError) { static Regex reg_name_addr ("^" SIPREG_DISPLAY_NAME "?" SIPREG_SWS "<[^\\r\\n]*>"); mPosition = buffer.GetPosition(); SetHypChosenId ( reg_name_addr.Match (buffer) ? id_nameAddr Loading @@ -1193,6 +1196,40 @@ void Addr_Union::PreDecode (Buffer& buffer) throw (DecodeError) ); } void Addr_Union::PostDecode (Buffer& buffer) throw (DecodeError) { if (GetChosenId() == id_addrSpecUnion) { Variable* parent = GetParent(); if (parent && ( (strcmp (parent->GetTypeName(), "From") == 0) || (strcmp (parent->GetTypeName(), "ContactAddress") == 0) || (strcmp (parent->GetTypeName(), "ReplyTo") == 0) || (strcmp (parent->GetTypeName(), "To") == 0) )) { // in the case we decoded an address not enclosed in <> in a // From, Contact, Reply-To or To header, then we must ensure // that it does not contain comma, semicolon or question mark const unsigned char* start = buffer.GetValueBin() + (mPosition/8); const unsigned char* end = buffer.GetValueBin() + (buffer.GetPosition()/8); for (const unsigned char* p=start ; p!=end ; p++) { switch (*p) { case ';': Get_addrSpecUnion().SetField (SipUrl::id_urlParameters, new Undef); case '?': Get_addrSpecUnion().SetField (SipUrl::id_headers, new Undef); buffer.SetPosition ((p-start) * 8 + mPosition); break; case ',': throw DecodeError (this, "Url must not contain unescaped comma, semicolor or question mark if it is not enclosed with <>\n"); default: ; } } } } } void ContactBody::PreDecode (Buffer& buffer) throw (DecodeError) { static Regex reg_asterisk ("^[*]"); Loading Loading
codec/c++/codec.h +3 −0 Original line number Diff line number Diff line Loading @@ -58,6 +58,9 @@ public: void Decode (Buffer& buffer) throw (DecodeError); }; // additional attributes #define DEFINITIONS_Addr_Union() int mPosition; }} //namespaces #endif // ----- #ifndef CODEC_INC ----- Loading
codec/c++/sip_codets.cpp +37 −0 Original line number Diff line number Diff line Loading @@ -1186,6 +1186,9 @@ void FieldName::Decode (Buffer& buffer) throw (DecodeError) void Addr_Union::PreDecode (Buffer& buffer) throw (DecodeError) { static Regex reg_name_addr ("^" SIPREG_DISPLAY_NAME "?" SIPREG_SWS "<[^\\r\\n]*>"); mPosition = buffer.GetPosition(); SetHypChosenId ( reg_name_addr.Match (buffer) ? id_nameAddr Loading @@ -1193,6 +1196,40 @@ void Addr_Union::PreDecode (Buffer& buffer) throw (DecodeError) ); } void Addr_Union::PostDecode (Buffer& buffer) throw (DecodeError) { if (GetChosenId() == id_addrSpecUnion) { Variable* parent = GetParent(); if (parent && ( (strcmp (parent->GetTypeName(), "From") == 0) || (strcmp (parent->GetTypeName(), "ContactAddress") == 0) || (strcmp (parent->GetTypeName(), "ReplyTo") == 0) || (strcmp (parent->GetTypeName(), "To") == 0) )) { // in the case we decoded an address not enclosed in <> in a // From, Contact, Reply-To or To header, then we must ensure // that it does not contain comma, semicolon or question mark const unsigned char* start = buffer.GetValueBin() + (mPosition/8); const unsigned char* end = buffer.GetValueBin() + (buffer.GetPosition()/8); for (const unsigned char* p=start ; p!=end ; p++) { switch (*p) { case ';': Get_addrSpecUnion().SetField (SipUrl::id_urlParameters, new Undef); case '?': Get_addrSpecUnion().SetField (SipUrl::id_headers, new Undef); buffer.SetPosition ((p-start) * 8 + mPosition); break; case ',': throw DecodeError (this, "Url must not contain unescaped comma, semicolor or question mark if it is not enclosed with <>\n"); default: ; } } } } } void ContactBody::PreDecode (Buffer& buffer) throw (DecodeError) { static Regex reg_asterisk ("^[*]"); Loading