Closed Bug 268619 Opened 20 years ago Closed 9 years ago

Port number validity checking function

Categories

(Core :: Networking, enhancement)

enhancement
Not set
normal

Tracking

()

RESOLVED INCOMPLETE

People

(Reporter: benc, Unassigned)

References

Details

Attachments

(1 file, 1 obsolete file)

This function is for checking the validity of a port number.

Here's the initial code:

function validatePort(portnumber) {
	if ((/^\d{1,5}$/).test(portnumber) ) {		
		if ( parseInt (portnumber, 10) < 65536) {	
			return (true)
			}
		return (false)
	}
return (false)

I've scanned the results of searching for "port" in bugzilla, and found several
places this would be useful:

Proxy prefs, image blocking, cookies, LDAP, mailnews, chatzilla. There might be
additional locations. (CCK and Installer also, assuming they use javascript).
Attached file test harness for function (obsolete) —
here is a test harness for the function. You can type in any values you think
should pass/fail, and see what the function returns.
Attached file test harness 2
opps, the top field/button was not working...
Attachment #165306 - Attachment is obsolete: true
This may sound silly, but "why do we care?"
mostly UI, but also having a consistent, correct function can help w/ a lot of
internal port number handling.
Blocks: 189253
James: see bug 189253.
Assignee: darin → nobody
QA Contact: benc → networking
Status: NEW → RESOLVED
Closed: 9 years ago
Resolution: --- → INCOMPLETE
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: