-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #59 from jumpserver/dev
v4.4.0
- Loading branch information
Showing
2 changed files
with
28 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
backend/framework/src/main/java/org/jumpserver/chen/framework/utils/CodeUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package org.jumpserver.chen.framework.utils; | ||
|
||
|
||
public class CodeUtils { | ||
|
||
/** | ||
* 对导出文件的换行符进行转义 | ||
* @param value | ||
* @return | ||
*/ | ||
public static String escapeCsvValue(String value) { | ||
if (value.contains("\"") || value.contains(",") || value.contains("\n")) { | ||
// 对引号进行转义 | ||
value = value.replace("\"", "\"\""); | ||
// 用引号包围值 | ||
value = "\"" + value + "\""; | ||
} | ||
return value; | ||
} | ||
} |