Closed Bug 191139 Opened 22 years ago Closed 22 years ago

unescape %80 using UTF-8 halts javascript execution

Categories

(Core :: DOM: Core & HTML, defect)

defect
Not set
normal

Tracking

()

RESOLVED DUPLICATE of bug 44272

People

(Reporter: francis.uy, Assigned: jst)

References

()

Details

Attachments

(1 file)

Years ago I wrote a javascript page to display the first 256 characters. It runs successfully on Netscape 4 and MSIE (Mac and Windows), as well as Safari, iCab, and Opera. Mozilla, however, dies on the first table row with the following javascript console message: Error: uncaught exception: [Exception... "Component returned failure code: 0x8000ffff (NS_ERROR_UNEXPECTED) [nsIDOMWindowInternal.unescape]" nsresult: "0x8000ffff (NS_ERROR_UNEXPECTED)" location: "JS frame :: http://jhunix.hcf.jhu.edu/~fuy/character-lister.html :: tablerow :: line 27" data: no] Further testing reveals that any attempt to unescape('%80') will halt the running javascript.
Attached file unescape 80 testcase (deleted) —
Work for me on Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.3b) Gecko/20030127 under WinXP.
Aha, I found the problem. I set default charset to UTF-8. If I switch to Latin 1 it works as expected. What's wrong with Unicode character 0x80?
Summary: unescape %80 halts javascript execution → unescape %80 using UTF-8 halts javascript execution
The DOM [un]escape() functions supersede the JS Engine versions in the browser. Reassigning to DOM Level 0. Note that escape(), unescape() were earlier functions in the language and are now deprecated. They appear only in the Appendix to ECMA-262 Edition 3. Instead, use encodeURI(), decodeURI(). Reference: http://devedge.netscape.com/library/manuals/2000/javascript/1.5/guide/fcns.html, where it states: ---- The escape and unescape functions let you encode and decode strings. The escape function returns the hexadecimal encoding of an argument in the ISO Latin character set. The unescape function returns the ASCII string for the specified hexadecimal encoding value. The syntax of these functions is: escape(string) unescape(string) These functions are used primarily with server-side JavaScript to encode and decode name/value pairs in URLs. The escape and unescape functions do not work properly for non-ASCII characters and have been deprecated. In JavaScript 1.5 and later, use encodeURI, decodeURI, encodeURIComponent, and decodeURIComponent. ---- I think that's why we get this DOM error on unescape('%80') when the browser's charset is set to UTF-8. Compare bug 44272, "javascript escape and unescape don't work properly with unicode chars" I think the present bug is either invalid, or a duplicate of that one -
Assignee: rogerl → jst
Component: JavaScript Engine → DOM Level 0
QA Contact: pschwartau → desale
Thanks for the explanation, Phil. This will remind me to put a meta content-type tag in all of my pages (especially ones that try to play games with non-ASCII characters). *** This bug has been marked as a duplicate of 44272 ***
Status: NEW → RESOLVED
Closed: 22 years ago
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: