Page MenuHomePhabricator

JavaScript Error: "Object expected" makes "Special Characters" section of (enhanced) toolbar of MW 1.18 unusable on IE 8
Closed, ResolvedPublic

Description

This was reported on [[WP:VPT]][1]:

Special characters is still not working with Vector XP IE8 - it just runs the loading symbol (lines round a ring) - left it running for 30 minutes - no change.

I confirmed this bug by opening the attached URL and clicking in the "Special characteres". IE 8 displayed the following error information:


Webpage error details

User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0)
Timestamp: Thu, 13 Oct 2011 17:34:04 UTC

Message: Object expected
Line: 560
Char: 10
Code: 0

URI: https://bits.wikimedia.org/w/extensions-1.18/WikiEditor/modules/jquery.wikiEditor.toolbar.js

The line 560 is part of the function buildCharacter and contains this:

} else if ( 0 in character && 1 in character ) {

The problem doesn't happens on Google Chrome 14.0.835.186 / Ubuntu 11.04.

[1] https://en.wikipedia.org/w/index.php?title=Wikipedia:Village_pump_(technical)&oldid=455400709#Editing_.22insert.22_box_not_showing


Version: unspecified
Severity: normal
URL: https://en.wikipedia.org/w/index.php?title=Wikipedia:Sandbox&action=edit&oldid=455397057&debug=1

Details

Reference
bz31673
TitleReferenceAuthorSource BranchDest Branch
Move swift_upload.py in refineryrepos/data-engineering/airflow-dags!570aquT336739_cleanup_ooziemain
Customize query in GitLab

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 21 2014, 11:56 PM
bzimport set Reference to bz31673.
bzimport added a subscriber: Unknown Object (MLST).

That's very strange. I wonder what the value of 'character' was in that case. 0 in character works fine if character is an array, and the "Object expected" error only seems to appear in cases where Firefox also throws an error.

IE8 specific. Does not reproduce on IE9.

(In reply to comment #2)

That's very strange. I wonder what the value of 'character' was in that case. 0
in character works fine if character is an array, and the "Object expected"
error only seems to appear in cases where Firefox also throws an error.

It's undefined.

I think it's caused by the stray comma at the end of line 752 in jquery.wikiEditor.toolbar.config.js

That apparently makes IE8 add a 185th undefined element to the array.

I think though, besides removing that comma, the function jquery.wikiEditor.toolbar.buildCharacter() should be made more robust by returning an empty string if typeof character == 'undefined'. Possibly log the error somewhere, but don't let such misconfigurations break the whole thing.

(In reply to comment #4)

(In reply to comment #2)

That's very strange. I wonder what the value of 'character' was in that case. 0
in character works fine if character is an array, and the "Object expected"
error only seems to appear in cases where Firefox also throws an error.

It's undefined.

I think it's caused by the stray comma at the end of line 752 in
jquery.wikiEditor.toolbar.config.js

Thanks for spotting that, removed in r102980. Deploying that now.

That apparently makes IE8 add a 185th undefined element to the array.

Well that's better than throwing a syntax error, which is what happens for trailing commas in object definitions :(

I think though, besides removing that comma, the function
jquery.wikiEditor.toolbar.buildCharacter() should be made more robust by
returning an empty string if typeof character == 'undefined'. Possibly log the
error somewhere, but don't let such misconfigurations break the whole thing.

There should probably be a typeof foo != 'string' check yeah.

make buildCharacter() more robust, and fix two other oversights

Besides testing whether "character" is defined at all, this patch also makes sure that the function returns something at all in all cases, otherwise, we might possibly again end up with "undefined" in the output (c.f. bug 24208).

Also supplies a missing end tag for the table row in buildHeading().

Attached:

Good work Lupo. I'll apply this in it's separate functional parts.

  • Bug 32797 has been marked as a duplicate of this bug. ***

(In reply to comment #5)

(In reply to comment #4)

(In reply to comment #2)
That apparently makes IE8 add a 185th undefined element to the array.

Well that's better than throwing a syntax error, which is what happens for
trailing commas in object definitions :(

I'd rather have the program throw up then silently add undefined.