Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JID parsing allows invalid JIDs #10

Open
SamWhited opened this issue Aug 17, 2018 · 0 comments
Open

JID parsing allows invalid JIDs #10

SamWhited opened this issue Aug 17, 2018 · 0 comments

Comments

@SamWhited
Copy link

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)
			}
		})
	}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant