Commit a3ebf746 authored by baire's avatar baire
Browse files

fixed decoding of HostPort

parent 2c193dae
Loading
Loading
Loading
Loading
+9 −8
Original line number Diff line number Diff line
@@ -205,19 +205,20 @@ void UserInfo::PreDecodeField (int id, Buffer& buffer) throw (DecodeError)

void HostPort::PreDecodeField (int id, Buffer& buffer) throw (DecodeError)
{
	static Regex reg_host1 ("^" SIPREG_HOST, REG_ICASE);
	static Regex reg_host2 ("^" SIPREG_HOST ":", REG_ICASE);
	static Regex reg_host ("^" SIPREG_HOST, REG_ICASE);
	static Regex reg_colon ("^:");

	switch (id) {
	case id_host:
		// host is always present
		SetHypFieldIsPresent(id, 1);
		if (reg_host2.Match(buffer)){
			SetHypFieldLength(id, reg_host2.GetMatchedLength() - 8);
		} else {
			reg_host1.AssertMatch(buffer, this);
		}

		reg_host.AssertMatch(buffer, this);
		SetHypFieldLength(id, reg_host.GetMatchedLength());
		break;

	case id_portField:
		if(buffer.GetBitsLeft()) {
		if(reg_colon.Match (buffer)) {
			buffer.SetPosition(buffer.GetPosition() + 8);
			SetHypFieldIsPresent (id, 1);
			Get_portField().SetFormat(Integer::AsciiDecimal);