parseInt will try to parse an octal when the string begins with a 0

RESOLVED INVALID

Status

()

Core
JavaScript Engine
RESOLVED INVALID
11 years ago
11 years ago

People

(Reporter: Manuel Vázquez Acosta, Unassigned)

Tracking

Trunk
x86
Linux
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

(Reporter)

Description

11 years ago
User-Agent:       Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1) Gecko/20060601 Firefox/2.0 (Ubuntu-edgy)
Build Identifier: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1) Gecko/20060601 Firefox/2.0 (Ubuntu-edgy)

This is documented in http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Functions:parseInt

However, it says "this feature is deprecated".

Besides, ECMAScript does not state so.

Reproducible: Always

Steps to Reproduce:
Test this HTML in Firefox 2:
<html>
	<body>
		<script type="text/javascript">
			document.write(Array( parseInt("07"), parseInt("08"), parseInt("09")));
		</script>
	</body>
</html>


Actual Results:  
7,0,0

Expected Results:  
7,8,9
Invalid.

<http://bclary.com/2004/11/07/#a-15.1.2.2>

12. If the length of S is at least 1 and the first character of S is "0", then at the implementation's discretion either let R = 8 or leave R unchanged.

14. If S contains any character that is not a radix- R  digit, then let Z be the substring of S consisting of all characters before the first such character; otherwise, let Z be S.

Both Firefox and MSIE agree on parseInt('07'), parseInt('08') and parseInt('09').


Status: UNCONFIRMED → RESOLVED
Last Resolved: 11 years ago
Resolution: --- → INVALID
(Reporter)

Comment 2

11 years ago
Opss, I missed that part of the spec. Sorry.
You need to log in before you can comment on or make changes to this bug.