CodeIgniter投掷“;您提交的URI包含不允许使用的字符";我可以';t see what'


CodeIgniter throwing "The URI you submitted has disallowed characters..." and I can't see what's causing it

我从CodeIgniter:得到这个错误

"您提交的URI包含不允许使用的字符……"

在这个JSON字符串上:

{"from":"feedback@myapp.com","to":"support@myapp.com","cc":"myadmin@ myapp.com, myfellowadmin@myapp.com","subject":"FROM APP: User Feedback","message":"FROM USER: testy.testerson@testme.com:'nHere's a test comment"}

当我尝试使用对其进行编码时

URLreadyJSON = encodeURIComponent(JSON.stringify(JsonObj));

(JsonObj是上面提到的JSON字符串。)

URLreadyJSON解析为:

https://127.0.0.1/Xhr/email/%7B%22from%22%3A%22feedback%40myapp.com%22%2C%22to%22%3A%22support%40myapp.com%22%2C%22cc%22%3A%22myadmin%40myapp.com%2C%20myfellowadmin%40myapp.com%22%2C%22subject%22%3A%22FROM%20APP%3A%20User%20Feedback%22%2C%22message%22%3A%22FROM%20USER%3A%20testy.testerson%40testme.com%3A%5CnHere's%20a%20test%20comment%22%7D

相关代码:

function sendFeedback() {
    JsonObj = { 
        'from': 'feedback@myapp.com',
        'to': 'support@myapp.com',
        'cc': 'myadmin@myapp.com, myfellowadmin@myapp.com',
        'subject': 'FROM APP: User Feedback',
        'message': 'FROM USER: ' + $('#feedback_email').val() + ":'n" + $('#feedback_message').val()
    }
    URLreadyJSON = encodeURIComponent(JSON.stringify(JsonObj));
    $.ajax({
        url: "/Xhr/email/" + URLreadyJSON,
        type: 'POST',
        dataType: 'json',
        success: function(data) {
            $('#feedback_feedback').text(data.message);
            if(!data.error) {
                $("#feedback_popup").popup("open");   // Open confirm popup
                $('#feedback_message').text('');      // Clear original message input
                $('#feedback_email').text('');        // Clear sender email
                setTimeout(function() { $("#feedback_popup").popup("close") }, 2500);
            }
        },
        fail: function(data) {
            console.log("FAIL");
            console.log(data);
        }
    });
}

最后,在我的CodeIgniter配置文件中,我将permitted_ur_chars设置为:

$config['permitted_uri_chars'] = 'a-z 0-9~%.,":_?&=;}{@-';

我已经研究了我能找到的所有解决这个错误的方法(有一些),并采纳了这些建议,但没有成功。我一定错过了什么,希望有人能看到那是什么。

尝试更改:-

$config['permitted_uri_chars'] = 'a-z 0-9~%.:_'-'=';

$config['permitted_uri_chars'] = 'a-z 0-9~%.:_'-'=+';
function sendFeedback() {
JsonObj = { 
    'from': 'feedback@myapp.com',
    'to': 'support@myapp.com',
    'cc': 'myadmin@myapp.com, myfellowadmin@myapp.com',
    'subject': 'FROM APP: User Feedback',
    'message': 'FROM USER: ' + $('#feedback_email').val() + ":'n" + $('#feedback_message').val()
}
$.ajax({
    url: "/Xhr/email/",
    type: 'POST',
    dataType: 'json',
    data : JsonObj, // add this
    success: function(data) {
        $('#feedback_feedback').text(data.message);
        if(!data.error) {
            $("#feedback_popup").popup("open");   // Open confirm popup
            $('#feedback_message').text('');      // Clear original message input
            $('#feedback_email').text('');        // Clear sender email
            setTimeout(function() { $("#feedback_popup").popup("close") }, 2500);
        }
    },
    fail: function(data) {
        console.log("FAIL");
        console.log(data);
    }
});

}

服务器端:

$from: $this->input->post('from',true);
$to: $this->input->post('to',true);
$cc: $this->input->post('cc',true);
$subject: $this->input->post('subject',true);
$message: $this->input->post('message',true);