Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

<EVAL>Javascript gets cut off if longer than 4000 characters #21

Open
berridgeab opened this issue Sep 15, 2015 · 1 comment
Open

<EVAL>Javascript gets cut off if longer than 4000 characters #21

berridgeab opened this issue Sep 15, 2015 · 1 comment

Comments

@berridgeab
Copy link

Weird issue, if JavaScript within an EVAL block exceeds 4000 characters, it seems to truncate the remaining script and then try to execute it. An error will be thrown by javascript due to the script being incomplete. Any ideas?

@berridgeab
Copy link
Author

I've managed to resolve the issue. The issue only seems to affect Firefox. I've tested Chrome and I.E and they seem to be unaffected.

Taconite processes nodes. If the node length is too long (Around 4000 characters) Firefox seems to split the nodes up in to multiple nodes. The fix is to process the remaining nodes.

Replace this code within the process() function.

        if (cmd == 'eval') {
            js = (cmdNode.firstChild ? cmdNode.firstChild.nodeValue : null);
            log('invoking "eval" command: ', js);
            if (js)
                $.globalEval(js);
            continue;
        }

With the following

if (cmd == 'eval') {
        js = '';
        for (ii = 0; ii < cmdNode.childNodes.length; ii++) {
                js += cmdNode.childNodes[ii].nodeValue;
        }

        log('invoking "eval" command: ', js);
        if (js.length)
                $.globalEval(js);
        continue;
}

As mentioned before the issue only seems to affect Firefox. Other browsers seem unaffected.

The fix simply loops over all available nodes and appends the data to one variable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant