Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
suliangchun
dbeaver
提交
de38167e
D
dbeaver
项目概览
suliangchun
/
dbeaver
与 Fork 源项目一致
从无法访问的项目Fork
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
dbeaver
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
de38167e
编写于
11月 03, 2020
作者:
S
Serge Rider
提交者:
GitHub
11月 03, 2020
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #10226 from dbeaver/cron#521
dbeaver/dbeaver-ee#521 add escaping to cron entry params
上级
3ac66ddf
3a4c5a9a
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
36 addition
and
0 deletion
+36
-0
bundles/org.jkiss.utils/src/org/jkiss/utils/CommonUtils.java
bundles/org.jkiss.utils/src/org/jkiss/utils/CommonUtils.java
+11
-0
test/org.jkiss.dbeaver.test.platform/src/org/jkiss/utils/CommonUtilsTest.java
...er.test.platform/src/org/jkiss/utils/CommonUtilsTest.java
+25
-0
未找到文件。
bundles/org.jkiss.utils/src/org/jkiss/utils/CommonUtils.java
浏览文件 @
de38167e
...
...
@@ -801,4 +801,15 @@ public class CommonUtils {
cal1
.
get
(
Calendar
.
YEAR
)
==
cal2
.
get
(
Calendar
.
YEAR
)
&&
cal1
.
get
(
Calendar
.
DAY_OF_YEAR
)
==
cal2
.
get
(
Calendar
.
DAY_OF_YEAR
));
}
public
static
String
escapeBourneShellString
(
@NotNull
String
s
)
{
return
"'"
+
s
.
replace
(
"'"
,
"'\\''"
)
+
"'"
;
}
public
static
String
unescapeBourneShellString
(
@NotNull
String
s
)
{
if
(!
s
.
startsWith
(
"'"
)
||
!
s
.
endsWith
(
"'"
)
||
s
.
length
()
<
2
)
{
//not an escaped bourne shell string
return
s
;
}
return
s
.
substring
(
1
,
s
.
length
()
-
1
).
replace
(
"'\\''"
,
"'"
);
}
}
test/org.jkiss.dbeaver.test.platform/src/org/jkiss/utils/CommonUtilsTest.java
浏览文件 @
de38167e
...
...
@@ -522,4 +522,29 @@ public class CommonUtilsTest {
public
void
testgetSingleLineString
()
{
Assert
.
assertEquals
(
"a¶bc d "
,
CommonUtils
.
getSingleLineString
(
"a\nb\rc\td\0"
));
}
@Test
public
void
testEscapeStringForBourneShell
()
{
Assert
.
assertEquals
(
"''"
,
CommonUtils
.
escapeBourneShellString
(
""
));
Assert
.
assertEquals
(
"'string'"
,
CommonUtils
.
escapeBourneShellString
(
"string"
));
Assert
.
assertEquals
(
"'string with '\\''one single quote symbol'"
,
CommonUtils
.
escapeBourneShellString
(
"string with 'one single quote symbol"
));
Assert
.
assertEquals
(
"'string with '\\''two '\\''single quote symbols'"
,
CommonUtils
.
escapeBourneShellString
(
"string with 'two 'single quote symbols"
));
Assert
.
assertEquals
(
"'string with '\\''three '\\''single '\\''quote symbols'"
,
CommonUtils
.
escapeBourneShellString
(
"string with 'three 'single 'quote symbols"
));
Assert
.
assertEquals
(
"''\\'''"
,
CommonUtils
.
escapeBourneShellString
(
"'"
));
Assert
.
assertEquals
(
"'unit'\\'''\\''test'"
,
CommonUtils
.
escapeBourneShellString
(
"unit''test"
));
Assert
.
assertEquals
(
"'unit'\\'''\\'''\\''test'"
,
CommonUtils
.
escapeBourneShellString
(
"unit'''test"
));
}
@Test
public
void
testUnescapeStringForBourneShell
()
{
Assert
.
assertEquals
(
""
,
CommonUtils
.
unescapeBourneShellString
(
"''"
));
Assert
.
assertEquals
(
"string"
,
CommonUtils
.
unescapeBourneShellString
(
"'string'"
));
Assert
.
assertEquals
(
"string with 'one single quote symbol"
,
CommonUtils
.
unescapeBourneShellString
(
"'string with '\\''one single quote symbol'"
));
Assert
.
assertEquals
(
"string with 'two 'single quote symbols"
,
CommonUtils
.
unescapeBourneShellString
(
"'string with '\\''two '\\''single quote symbols'"
));
Assert
.
assertEquals
(
"string with 'three 'single 'quote symbols"
,
CommonUtils
.
unescapeBourneShellString
(
"'string with '\\''three '\\''single '\\''quote symbols'"
));
Assert
.
assertEquals
(
"'"
,
CommonUtils
.
unescapeBourneShellString
(
"''\\'''"
));
Assert
.
assertEquals
(
"unit''test"
,
CommonUtils
.
unescapeBourneShellString
(
"'unit'\\'''\\''test'"
));
Assert
.
assertEquals
(
"unit'''test"
,
CommonUtils
.
unescapeBourneShellString
(
"'unit'\\'''\\'''\\''test'"
));
Assert
.
assertEquals
(
"'''unit'''test'''"
,
CommonUtils
.
unescapeBourneShellString
(
"''\\'''\\'''\\''unit'\\'''\\'''\\''test'\\'''\\'''\\'''"
));
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录