I have been tasked to add a javascript code from CoreMotives to track webstats. However, when I add the code, the website becomes a white screen with the text “Disallowed Key Characters”. The only way to view the site is to delete the cookies and hit refresh. And then if you want to navigate to a different part of the website, you get the error again, then you gotta delete cookies and hit refresh. It’s a whole big mess. I know that the issue is with the percentage sign in the cookie names. That is what is causing the “Disallowed Key Characters”.
My question is, how do I fix this? Do I need to update our Security Settings so that percentage signs are allowed? If we do that, is that a bad things? Or does the code need to be re-written so that there won’t be percentage signs? Or are the percentage signs inevitable because the point of the code is to track user visits?
We need to get this code on our site so I need to know how we can make this work.
Please help!
Thanks in advance.
Thank you for the response. Unfortunately, I am not a web developer so I don’t exactly understand what your suggestion means.
Use url_encode(), url_decode() in PHP and use encodeURIComponent(), decodeURIComponent() in JavaScript
We also do not have a web developer on staff. Can you please clarify? Also where exactly would this snippet of code go?
FYI, here is the code in question that I am trying to implement which would go in the footer template at the very bottom of the page.
[removed]
var cmJsHost = (("https:" == document.location.protocol) ? "https://" : "http://");
var path = "databroker.coremotives.com/DataBroker.js?version=2";
[removed](unescape("[removed][removed]"));
[removed]
[removed]
try {
var coreMotives = new DataBroker();
coreMotives.customerId = "5a05bf77-94a0-e211-b5f7-00155d32390f";
coreMotives.instanceId = 1454;
coreMotives.trackPageView();
} catch (e) { }
[removed]
Hi krozo,
Are you on the latest version of ExpressionEngine? We fixed this issue in EE 2.5.3 so that EE only cleans its own cookies so that you can have other cookes like the ones your webstats tracker is setting. It was a common issue for other folks too so we made that change to help folks out.
Kevin
Hi Krozo, I just ran into this problem. The coremotives code I was using had a vertical bar character | in the cookie. In the expressionengin/config/config.php file, there is a $config[‘permitted_uri_chars’] parameter. I added a vertical bar character to this parameter and that seemed to get it working. Maybe someone else can weigh in on any ramifications of adding this to the permitted_uri_chars? And Kevin, I was still getting this issue in version 2.5.3.
Edit: Perhaps I spoke to soon, still haven’t resolved the issue.
Edit: OK I got a temporary fix in place. In the system/codeigniter/system/core/input.php file, the _clean_input_keys function does not allow the vertical bar character. I’ve added it here:
if ( ! preg_match("/^[a-z0-9:_\/-|]+$/i", $str))
{
set_status_header(503);
exit('Disallowed Key Characters.');
}
As a note, this is changing a core file, so be aware this may need to be adjusted when updating EE.
Hi Krozo, I just ran into this problem. The coremotives code I was using had a vertical bar character | in the cookie. In the expressionengin/config/config.php file, there is a $config[‘permitted_uri_chars’] parameter. I added a vertical bar character to this parameter and that seemed to get it working. Maybe someone else can weigh in on any ramifications of adding this to the permitted_uri_chars? And Kevin, I was still getting this issue in version 2.5.3.Edit: Perhaps I spoke to soon, still haven’t resolved the issue. Edit: OK I got a temporary fix in place. In the system/codeigniter/system/core/input.php file, the _clean_input_keys function does not allow the vertical bar character. I’ve added it here:As a note, this is changing a core file, so be aware this may need to be adjusted when updating EE.if ( ! preg_match("/^[a-z0-9:_\/-|]+$/i", $str)) { set_status_header(503); exit('Disallowed Key Characters.'); }
Nope, that didn’t end up working either. Instead I defined the cookie prefix in my config file. This cleared up the problem:
$config['cookie_prefix'] = 'im_';
This error bugged me for days. Thanks to Derwin Biler’s blog, I found the answer. In the system/codeigniter/system/core/input.php file:
Find the function _clean_input_keys($str)
Change:
exit(‘Disallowed Key Characters.’);
to:
exit(‘Disallowed Key Characters.’. $str);
This will tell you what characters are causing you problems. Then you can follow the suggestions above to add them to the regex string. In my case, I just changed the input’s name.
I tried the solution to add $str on to the end of the code and I got this /cp/content_publish/entry_form?channel_id I only get the error when I am in the CMS side of the website. When a user is filling out the fields to submit a new entry the vast majority of the time the error will not appear but every so often it does. I can eliminate some of the copy for the new article and piece it back line by line and that will allow me to hone in on the “offending character” but it is just a letter. Not something that would throw an error. I tried inserting the “|” character but that did not work. I think the solution to add “$config[‘cookie_prefix’] = ‘im_’;” to the config.php file is promising but I can you tell me what line to add the code to?
Well if you give me a few days I can ask my developer friend who works write my thesis UK which is an online platform in the UK.
Please continue to support Drift Hunters and join me in discovering the next exciting things the game has to offer!
It sounds like you’re encountering an issue with special characters, specifically the percentage sign, To resolve this issue, I will have to ask assignment help Dubai team to guide you on this, they are incredible in researching.
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.