Opened 12 years ago

Closed 10 years ago

#8659 closed Bug (fixed)

SCAYT + SyntaxHighlighter conflict

Reported by: Anna Tomanek Owned by:
Priority: Normal Milestone:
Component: UI : Spell Checker Version: 3.0
Keywords: Cc: WebSpellChecker.net

Description

As reported in: http://cksource.com/forums/viewtopic.php?f=11&t=24453

Problem:
On a page which uses Alex Gorbatchev's SyntaxHighlighter and has a CKEditor instance with SCAYT enabled, a script error is thrown when pasting into the editor.

In Firefox, the error is similar to: "e is undefined", shCore.js line 17.
In IE, the error is similar to "Unable to get value of the property 'valueOf': object is null or undefined", http://svc.webspellchecker.net/scayt26/_base.xd.js, line 3268.

Cause:
SyntaxHighlighter uses the XRegExp library, which replaces the native String.prototype.replace(search, replacement) function. SCAYT seems to call the replace function without passing the replacement parameter. The new replace function attempts to call valueOf on the replacement parameter, which throws the error.

This appears to be a bug in SCAYT; however, the native replace function will convert an undefined parameter to the string "undefined", which would mask this problem.

Workaround:
Override the new replace function to cope with an undefined replacement parameter:

    jQuery(function(){
        var oldReplace = String.prototype.replace;
        String.prototype.replace = function (search, replacement) {
            if ("undefined" === typeof(replacement)) { replacement = ""; }
            return oldReplace.call(this, search, replacement);
        };
    });

The affected line in the SCAYT code is:

    if(node.nodeName.match(t.nextNode.blockElementsRegex)
    &&this.text.replace(/\s/).length!=""){

This should be:

    if(node.nodeName.match(t.nextNode.blockElementsRegex)
    &&this.text.replace(/\s/,"").length!=0){

Change History (3)

comment:1 Changed 12 years ago by WebSpellChecker.net

WebSpellChecker.net team confirms the problem and offered resolution. The fix will be released during the next release of SCAYT core which will be scheduled during next few weeks.

comment:2 Changed 12 years ago by Jakub Ś

Status: newconfirmed
Version: 3.6.23.0

comment:3 Changed 10 years ago by Piotrek Koszuliński

Resolution: fixed
Status: confirmedclosed
Note: See TracTickets for help on using tickets.
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy