通过 GET 传递带有新行的文本字符串会破坏我的重定向

Passing text string with new lines through GET is breaking my redirect

本文关键字:字符串 重定向 我的 文本 GET 新行 通过      更新时间:2023-09-26

>我正在提交一个使用 javascript 通过 GET 传递值的表单 - 当它到达提交页面时,它会运行函数,然后在通过标头重定向时运行空白页。标头通过重定向再次传递 GET:

header("location: page.php?name=" . $name . "&number=" . $number);

正在传递的值在文本中使用新行 -

function selectvalue()
    {
        var frm = document.forms[0];
        var select = frm.browsers.value;
        if (select === "A")
            frm.message.value = "lineone'nlinetwo'nlinethree";
        else if (select === "B")
            frm.message.value = "lineone'nlinetwo'nlinethree";
        else
            frm.message.value = "lineone'nlinetwo'nlinethree";
    }

提交单行工作正常,只有多行消息。任何协助将不胜感激。

您应该使用 encodeURI 将其转换为有效的 URL