Skip to content

JID parsing allows invalid JIDs #10

Description

@SamWhited

Hi, thanks for the work you've done on this library! I've been experimenting with different Go XMPP libraries to try and make the existing ones more robust, and the following tests will fail with your current JID parsing implementation. All of these are invalid JIDs according to RFC 7622 (feel free to use these tests however you see fit):

var invalidutf8 = string([]byte{0xff, 0xfe, 0xfd})
var invalidJIDs = [...]string{
	0:  "test@/test",
	1:  invalidutf8 + "@example.com/rp",
	2:  invalidutf8 + "/rp",
	3:  invalidutf8,
	4:  "example.com/" + invalidutf8,
	5:  "lp@/rp",
	6:  `b"d@example.net`,
	7:  `b&d@example.net`,
	8:  `b'd@example.net`,
	9:  `b:d@example.net`,
	10: `b<d@example.net`,
	11: `b>d@example.net`,
	12: `e@example.net/`,
	13: `@example.net/`,
}

func TestInvalidParseJIDs(t *testing.T) {
	for i, tc := range invalidJIDs {
		t.Run(strconv.Itoa(i), func(t *testing.T) {
			_, err := ParseJID(tc)
			if err == nil {
				t.Errorf("Expected JID %s to fail", tc)
			}
		})
	}
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions