Port number validity checking function

RESOLVED INCOMPLETE

Status

()

Core
Networking
--
enhancement
RESOLVED INCOMPLETE
14 years ago
2 years ago

People

(Reporter: benc, Unassigned)

Tracking

Trunk
Points:
---
Dependency tree / graph

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment, 1 obsolete attachment)

1.98 KB, text/html
Details
(Reporter)

Description

14 years ago
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).
(Reporter)

Comment 1

14 years ago
Created attachment 165306 [details]
test harness for function

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.
(Reporter)

Comment 2

14 years ago
Created attachment 165307 [details]
test harness 2

opps, the top field/button was not working...
Attachment #165306 - Attachment is obsolete: true

Comment 3

14 years ago
This may sound silly, but "why do we care?"
(Reporter)

Comment 4

14 years ago
mostly UI, but also having a consistent, correct function can help w/ a lot of
internal port number handling.
(Reporter)

Updated

14 years ago
Blocks: 189253
(Reporter)

Comment 5

14 years ago
James: see bug 189253.

Updated

12 years ago
Assignee: darin → nobody
QA Contact: benc → networking
Status: NEW → RESOLVED
Last Resolved: 2 years ago
Resolution: --- → INCOMPLETE
You need to log in before you can comment on or make changes to this bug.