magic_quotes_gpc ColdFusion 的设置?冷藏箱?

magic_quotes_gpc setting for ColdFusion? ColdBox?

我是 ColdFusion 的新手,想从输入字段的值中删除单引号。我尝试在 google 上搜索,我发现是使用 "magic_quotes_gpc" 或 "mysql_real_escape_string",但这些函数在 ColdFusion 中不存在。在 ColdFusion 中有什么方法可以处理这种 mysql 查询注入?

更新:

感谢您的回复,但请看我的代码

<div class="form-group">
    <label for="jobDesc">Job description</label>
    <textarea name="description" class="form-control" rows="3" id="jobDesc">
        <cfif isdefined('userTime')>#userTime.description#</cfif>        
   </textarea>
</div>

我只想在文本区域使用单引号,我的表单正在提交给活动。查询是:

 sqlstr = "";
          sqlstr = "insert into usertime set
          userid = '#arguments.userTimeParams.userid#',
          projectid = '#arguments.userTimeParams.projectid#',
          timesheetdate = '#arguments.userTimeParams.timesheetdate#',
          estimatedtimespent = '#arguments.userTimeParams.jobhours * 60 + arguments.userTimeParams.jobMins#',
          description = '#arguments.userTimeParams.description#',
          timeentered = #arguments.userTimeParams.timeentered#;";

            queryObj = new query();
            queryObj.setDatasource("timesheet");
            queryObj.setName("adduserTime");
            result = queryObj.execute(sql=sqlstr);
            adduserTime = result.getResult();
            return result.getPrefix().generatedKey;

我有一个选项可以在我的字符串中添加斜杠,但我必须在所有字符串中添加斜杠。那么有没有什么功能或方法可以用更少的代码行来做到这一点?

知识有限,问的太多了

嗯...只是不要传递在 SQL 语句中硬编码的用户输入(或任何其他数据〜)值,而是将它们作为参数值传递。

示例:

coloursViaQueryExecute = queryExecute("
    SELECT  en AS english, mi AS maori
    FROM    colours
    WHERE   id BETWEEN :low AND :high 
    ",
    {low=URL.low, high=URL.high},
    {datasource="scratch_mssql"}
);

其中 lowhigh 是您的参数。

查看相关文档@QueryExecute()

以及关于该主题的进一步阅读:

如果不对用户数据进行参数化,您就是在向 SQL 注入开放自己。 REReplace() 可能无法捕获所有内容。以下是您应该如何重写该代码以使用 cfqueryparam。您可能需要调整 addParam() 方法调用以添加正确的 cfsqltype.

sqlstr = "";
      sqlstr = "insert into usertime set
      userid = :userid,
      projectid = :projectid,
      timesheetdate = :timesheetdate,
      estimatedtimespent = :estimatedtimespent,
      description = :description,
      timeentered = :timeentered";

        queryObj = new query();
        queryObj.setDatasource("timesheet");
        queryObj.setName("adduserTime");
        queryObj.addParam( name="userid", value=arguments.usertimeparams.userid);
        queryObj.addParam( name="projectid", value=arguments.usertimeparams.projectid);
        queryObj.addParam( name="timesheetdate", value=arguments.usertimeparams.timesheetdate, cfsqltype="CF_SQL_TIMESTAMP");
        queryObj.addParam( name="estimatedtimspent", value=arguments.userTimeParams.jobhours * 60 + arguments.userTimeParams.jobMins, cfsqltype="CF_SQL_INTEGER");
        queryObj.addParam( name="description", value=arguments.usertimeparams.description);
        queryObj.addParam( name="timeentered", value=arguments.usertimeparams.timeentered, cfsqltype="CF_SQL_INTEGER");
        result = queryObj.execute(sql=sqlstr);
        adduserTime = result.getResult();
        return result.getPrefix().generatedKey;