Skip to content

Commit

Permalink
fix escaption issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Bosn committed Feb 19, 2014
1 parent e73dfcf commit e595539
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 18 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,10 @@ RAP提供MOCK服务插件(暂时仅支持Kissy和jQuery),使用方法只
### 在kissy, jQuery后面引入rap plugin ###

```bash
<script type="text/javascript" src="http://rap.alibaba-inc.com/rap.plugin.js?id={{id}}&mode={{mode}}"></script>
<script type="text/javascript" src="http://rap.alibaba-inc.com/rap.plugin.js?projectId={{projectId}}&mode={{mode}}"></script>
```

其中`{{id}}`为RAP提供的项目ID, `{{mode}}`为RAP路由的工作模式, 默认值为3,白名单会根据RAP中的文档自动配置,对RAP中未录入的接口不会做拦截。
其中`{{projectId}}`为RAP提供的项目ID, `{{mode}}`为RAP路由的工作模式, 默认值为3,白名单会根据RAP中的文档自动配置,对RAP中未录入的接口不会做拦截。
mode不同值具体含义:
- 0 - 不拦截
- 1 - 拦截全部
Expand Down
5 changes: 5 additions & 0 deletions UPDATELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
### rap v1.0 ###
* [BUG] 修复工作区数据projectData中包含特殊字符导致提交失败、系统异常的问题。2014-02-19
* [BUG] 修复Mock标签包含单引号时项目不能正常编辑的错误 2014-02-19
* [BUG] 修复Mock标签包含空格时不能正常过滤的错误 2014-02-18

### rap v0.8 ###
* [改进] 改进编辑状态下的样式 2014-02-12
* [BUG] 修复新版CSS导致模块不能删除的问题 2014-02-12
Expand Down
2 changes: 1 addition & 1 deletion WebContent/WEB-INF/web.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
</init-param>
<init-param>
<param-name>EXCLUSIONS</param-name>
<param-value>*/stat/*,*/favicon.ico,/t/*,/crossdomain.xml,/*.htm,/*.html,*.md</param-value>
<param-value>*/stat/*,*/favicon.ico,/t/*,/crossdomain.xml,/*.htm,/*.html,*.md,*/mock/*,*/mockjs/*</param-value>
</init-param>
</filter>
<filter>
Expand Down
6 changes: 3 additions & 3 deletions WebContent/mock/createPluginScript.vm

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion WebContent/plugin/rap.mock.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
}
}
var enable = true;
console.log('Current RAP work mode:', mode, "(0-disabled, 1-black list, 2-white list, 3-combo)");
console.log('Current RAP work mode:', mode, "(0-disabled, 1-intercept all requests, 21-black list, 3-white list)");
var ens = node.src.match(/(?:\?|&)enable=([^&]+)(?:&|$)/);
if (ens) {
enable = ens[1] == 'true';
Expand Down
32 changes: 22 additions & 10 deletions WebContent/stat/js/core/rap.js
Original file line number Diff line number Diff line change
Expand Up @@ -1548,7 +1548,7 @@ var rap = rap || {};
if (!processing()) return;
b.ajax.post(URL.checkIn, q, function(xhr, response) {
try {
var obj = JSON.parse(response);
var obj = eval("(" + response + ")");
p.init(obj.projectData);
_data.projectDataOriginal = b.object.clone(obj.projectData);
b.g(ELEMENT_ID.CHECKIN_PANEL_CONTENT).innerHTML = obj.log ? obj.log : TEMPLATE.NO_DATA_CHECKED;
Expand Down Expand Up @@ -1608,7 +1608,7 @@ var rap = rap || {};
if (!processing(ELEMENT_ID.SAVE_PANEL_MESSAGE)) return;
b.ajax.post(URL.removeSave, "id=" + _data.id + "&saveId=" + save.id, function(xhr,response) {
try {
var obj = JSON.parse(response);
var obj = eval("(" + response + ")";
_data.saveList = obj.saveList;
initSavePanel();
showMessage(CONST.LOAD, ELEMENT_ID.SAVE_PANEL_MESSAGE, MESSAGE.DELETED);
Expand Down Expand Up @@ -1729,7 +1729,7 @@ var rap = rap || {};
alert('您用的啥浏览器啊?连JSON转换都不支持也~~~请考虑用新浏览器试试?谢谢啦,mua~~~!');
return;
}
var data = JSON.parse(txt);
var data = eval("(" + txt + ")");

if (data instanceof Array) {
data = data[0];
Expand Down Expand Up @@ -1926,7 +1926,8 @@ var rap = rap || {};
if (!processing(ELEMENT_ID.WORKSPACE_MESSAGE)) return;
b.ajax.post(URL.lock, q, function(xhr, response) {
try {
var obj = JSON.parse(response);
response = jsonFilter(response);
var obj = eval("(" + response + ")");
if (obj.isOk) {
storeViewState();
if (obj.projectData.moduleList.length === 0) {
Expand Down Expand Up @@ -1980,7 +1981,7 @@ var rap = rap || {};
if (!processing(ELEMENT_ID.WORKSPACE_MESSAGE)) return;
b.ajax.post(URL.checkIn, q, function(xhr, response) {
try {
var obj = JSON.parse(response);
var obj = eval("(" + response + ")");
if (obj.isOk) {
p.init(obj.projectData);
_data.projectDataOriginal = b.object.clone(obj.projectData);
Expand Down Expand Up @@ -2010,7 +2011,7 @@ var rap = rap || {};
if (!processing(ELEMENT_ID.VSS_PANEL_MESSAGE)) return;
b.ajax.post(URL.checkIn, q, function(xhr, response) {
try {
var obj = JSON.parse(response);
var obj = eval("(" + response + ")");
if (obj.isOk) {
p.init(obj.projectData);
_data.projectDataOriginal = b.object.clone(obj.projectData);
Expand Down Expand Up @@ -2062,7 +2063,7 @@ var rap = rap || {};
if (!processing(ELEMENT_ID.VERSION_PANEL_MESSAGE)) return;
b.ajax.post(URL.queryVersion, q, function(xhr, response) {
try {
var obj = JSON.parse(response);
var obj = eval("(" + response + ")");
p.init(obj.projectData);
setButtonsViewState(CONST.VERSION);
_isEditMode = false;
Expand Down Expand Up @@ -2104,7 +2105,7 @@ var rap = rap || {};
if (!processing(ELEMENT_ID.VERSION_PANEL_MESSAGE)) return;
b.ajax.post(URL.switchVersion, q, function(xhr, response) {
try {
var obj = JSON.parse(response);
var obj = eval("(" + response + ")");
if (obj.isOk) {
p.init(obj.projectData);
showMessage(CONST.LOAD, ELEMENT_ID.WORKSPACE_MESSAGE, MESSAGE.VERSION_SWITCHED);
Expand Down Expand Up @@ -2295,7 +2296,7 @@ var rap = rap || {};
function sessionDelay() {
b.ajax.get(URL.ping, function(xhr, response) {
try {
var obj = JSON.parse(response);
var obj = eval("(" + response + ")");
if (obj.isOk) {
} else {
showMessage(CONST.WARN, ELEMENT_ID.WORKSPACE_MESSAGE, MESSAGE.SESSION_DELAY_ERROR);
Expand Down Expand Up @@ -3328,7 +3329,7 @@ var rap = rap || {};
}
if (!r) return '';
// 感谢@逸才 提供正则表达式
return r.replace(/[\s;]?@\w+=[^ ;]+[ ;]?/g, '');
return r.replace(/[\s;]?@\w+=[^;]+[ ;]?/g, '');
}

/**
Expand All @@ -3342,6 +3343,17 @@ var rap = rap || {};
return r.replace(/\|.*$/g, '');
}

/**
* escaption handler
*/
function jsonFilter(s) {
if (!s) return '';
s = s.replace(/\\'/g, "'");
s = s.replace();
return s;
}


/**
* get edit input element
*/
Expand Down
2 changes: 1 addition & 1 deletion WebContent/tester/pageTester.vm
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<body>
<h3>$!utils.escapeInH($page.name)控制台</h3>
<div id="divRootSetting">
<input id="txtRootPath" type="text" style="width:500px;" value="rap.alibaba-inc.com$!projectContext/mock/$!projectId"></input>
<input id="txtRootPath" type="text" style="width:500px;" value="rap.alibaba-inc.com$!projectContext/mockjs/$!projectId"></input>
<span style="color:#666;">* 根路径设置</span>
</div>
<div id="divActionList" class="demo tabs">
Expand Down

0 comments on commit e595539

Please sign in to comment.