ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Padded JSON string causes "Disallowed Key Characters" error

March 29, 2010 1:43pm

Subscribe [3]
  • #1 / Mar 29, 2010 1:43pm

    Laisvunas

    879 posts

    Hi,

    I have one template which should output padded JSON string. If I put the URL of this template into browser’s navigation bar, I get correct output. You can see it by clicking this link:

    http://www.classicsunlocked.net/index.php/ebook/jsonp_commentsNumber/?bubble_comments_basic_analysis=201&bubble_comments_morphology=202&bubble_comments_syntax=203&bubble_comments_dictionary=205&bubble_comments_commentary=204&bubble_comments_prosody=206

    But when I use URL of this template as intended, i.e. to output a string to be evaluated by already defined javascript function, as here

    url= "http://www.classicsunlocked.net/index.php/ebook/jsonp_commentsNumber/?bubble_comments_basic_analysis=201&bubble_comments_morphology=202&bubble_comments_syntax=203&bubble_comments_dictionary=205&bubble_comments_commentary=204&bubble_comments_prosody=206";
    
        // create script tag
        var script = document.createElement("script");
        script.setAttribute("type", "text/javascript");
    
        // set script source to the service that responds with the padded JSON data
        script.setAttribute("src", url);
    
        // insert script tag
        document.getElementsByTagName('head')[0].appendChild(script);

    I get “Disallowed Key Characters” error.

    It seems that the template in both cases should output the same padded JSON string, isn’t it? What can cause “Disallowed Key Characters” error?

    I use EE v 1.6.8 build:  20100121.

  • #2 / Mar 29, 2010 7:32pm

    Brandon Jones

    5500 posts

    Hi Laisvunas,

    How are you running that script?  Is it in another template on the same site?  Does it make a difference if the script runs when you are logged out of the site?

    Try changing line 448 of /system/core/core.input.php from

    exit('Disallowed Key Characters');

    to

    exit('Disallowed Key Characters: '.$str);

    ...and let us know the output.

  • #3 / Mar 30, 2010 3:51am

    Laisvunas

    879 posts

    Hi Brandon,

    After changing the line 448 of /system/core/core.input.php I get this output:

    Disallowed Key Charactersamp;time

    There is no difference if I’m logged in or logged out.

    In case the line 448 of /system/core/core.input.php is commented out everything works as expected.

  • #4 / Mar 30, 2010 3:58am

    Laisvunas

    879 posts

    Hi again,

    Found the culprit! One ampersand symbol in URL was unintentionally converted into HTML entity.

    Thanks for your help, Brandon!

  • #5 / Mar 30, 2010 4:12am

    John Henry Donovan

    12339 posts

    Glad you are up and running. Feel free to start a new thread if you have any more questions

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases