sql injection violation, syntax error: syntax error, error in :‘**‘expect IDENTIFIER, actual IDENTIF

简介: sql injection violation, syntax error: syntax error, error in :‘**‘expect IDENTIFIER, actual IDENTIF

java.sql.SQLException: sql injection violation, syntax error: syntax error, error in :'soft YaHei UI'"><span style="color:', expect IDENTIFIER, actual IDENTIFIER pos 1935, line 5, column 1136, token IDENTIFIER YaHei

一、背景描述

项目架构:Springboot(2.0.1) + Mybatis(3.4.1) + CKEditor(4.8)

最近在发布文章的时候后台SQL语句突然报错,java.sql.SQLException: sql injection violation, syntax error: syntax error, error in :'soft YaHei UI'"><span style="color:', expect IDENTIFIER, actual IDENTIFIER pos 1935, line 5, column 1136, token IDENTIFIER YaHei,说是SQL注入有问题;一直都在线上稳定运行,怎么突然就报SQL异常了呢?下图是MyBatis打印出来的SQL语句,经过分析得出,Microsoft YaHei UI被识别为分隔符了。最终导致SQL INSERT语句报错。

二、错误原因

根据日志打印出来的报错信息,java.sql.SQLException: sql injection violation, syntax error: syntax error, error in :'soft YaHei UI'"><span style="color:', expect IDENTIFIER, actual IDENTIFIER pos 1935, line 5, column 1136, token IDENTIFIER YaHei,SQL异常,语法错误,分析得出,肯定是SQL语句拼装的不正确导致注入失败。将日志信息复制到数据库中,美化SQL对比得出,我发布文章的时候,有字符被识别为分隔符了,结果就是SQL注入失败。

三、解决方案

根据错误原因,可以得出解决方案有以下几个:

3.1 方案一

在富文本编辑器里把被识别为分隔符的符号或者文字删除,然后重新交给Mybatis解析即可。

3.2 方案二

修改富文本编辑器里的文字字体,只要不被Mybatis识别为分隔符即可。针对本次错误,我采取的方案是,将富文本编辑器里的文字字体由微软雅黑改为宋体。

 

 

 

完结!


相关文章
|
4月前
|
SQL 关系型数据库 MySQL
SQL Error (2013): Lost connection to MySQL server at 'waiting for initial communication packet', sys...
SQL Error (2013): Lost connection to MySQL server at 'waiting for initial communication packet', sys...
|
4月前
|
SQL Java 关系型数据库
实时计算 Flink版操作报错之如何处理从源表插入数据到结果表报错误:[ERROR] Could not execute SQL statement.
在使用实时计算Flink版过程中,可能会遇到各种错误,了解这些错误的原因及解决方法对于高效排错至关重要。针对具体问题,查看Flink的日志是关键,它们通常会提供更详细的错误信息和堆栈跟踪,有助于定位问题。此外,Flink社区文档和官方论坛也是寻求帮助的好去处。以下是一些常见的操作报错及其可能的原因与解决策略。
|
22天前
|
SQL Java 数据库连接
Mybatis系列之 Error parsing SQL Mapper Configuration. Could not find resource com/zyz/mybatis/mapper/
文章讲述了在使用Mybatis时遇到的资源文件找不到的问题,并提供了通过修改Maven配置来解决资源文件编译到target目录下的方法。
Mybatis系列之 Error parsing SQL Mapper Configuration. Could not find resource com/zyz/mybatis/mapper/
|
24天前
|
SQL 关系型数据库 MySQL
解决:Mybatis-plus向数据库插入数据的时候 报You have an error in your SQL syntax
该博客文章讨论了在使用Mybatis-Plus向数据库插入数据时遇到的一个常见问题:SQL语法错误。作者发现错误是由于数据库字段中使用了MySQL的关键字,导致SQL语句执行失败。解决方法是将这些关键字替换为其他字段名称,以避免语法错误。文章通过截图展示了具体的操作步骤。
|
29天前
|
SQL 安全 网络安全
SQL注入(SQL Injection)
【8月更文挑战第11天】
40 3
|
2月前
|
SQL 安全 网络安全
DVWA SQL Injection (Blind) 通关解析
DVWA SQL Injection (Blind) 通关解析
|
2月前
|
SQL 关系型数据库 MySQL
【Python】已解决:ERROR 1064 (42000): You have an error in your SQL syntax. check the manual that correspo
【Python】已解决:ERROR 1064 (42000): You have an error in your SQL syntax. check the manual that correspo
88 0
|
2月前
|
SQL 关系型数据库 MySQL
You have an error in your SQL syntax;check the manual that corresponds to you Mysql server version
You have an error in your SQL syntax;check the manual that corresponds to you Mysql server version
|
3月前
|
SQL 存储 关系型数据库
1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server
1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server
|
3月前
|
SQL 关系型数据库 MySQL
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version