mirror of
https://gitee.com/willfree/MINResolveV2.git
synced 2026-06-03 08:16:55 +08:00
所有发送兴趣包之前,都对要发送的前缀进行判断,如果不是正确格式,就不发送该兴趣包
This commit is contained in:
+28
-6
@@ -456,10 +456,8 @@ function isIncludedRules(urlString) {
|
||||
}
|
||||
}
|
||||
|
||||
// 判断某个字符串是否是映射表的一个前缀表项
|
||||
// 判断某个字符串是否包含映射表中的表项
|
||||
function isRulesPrefix(urlString) {
|
||||
// 先进行模糊判断
|
||||
// 模糊判断一个string是否是一个合法前缀
|
||||
function isRightfulPrefix(urlString){
|
||||
if(urlString===''){
|
||||
return false;
|
||||
}
|
||||
@@ -470,6 +468,27 @@ function isRulesPrefix(urlString) {
|
||||
// alert("没/");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// 判断某个字符串是否是映射表的一个前缀表项
|
||||
// 判断某个字符串是否包含映射表中的表项
|
||||
function isRulesPrefix(urlString) {
|
||||
// alert("要判断的urlString: "+urlString);
|
||||
// 先进行模糊判断
|
||||
// if(urlString===''){
|
||||
// return false;
|
||||
// }
|
||||
// if(urlString.indexOf('.')>=0){
|
||||
// return false;
|
||||
// }
|
||||
// if((urlString.indexOf('/')!==0)&&(urlString.indexOf('%2F')!==0)){
|
||||
// // alert("没/");
|
||||
// return false;
|
||||
// }
|
||||
if(!isRightfulPrefix(urlString)){
|
||||
return false;
|
||||
}
|
||||
// 再遍历本地映射表
|
||||
var flag=0;
|
||||
for (var i=0; i<storage.customRules.length; i++) {
|
||||
@@ -588,7 +607,8 @@ function handleRedirect(details) {
|
||||
// 则根据该内容更新本地缓存之后,进行重定向
|
||||
if(searchContent!==""){
|
||||
// alert("检索内容了呢:"+searchContent);
|
||||
if (misEnableState === true) {
|
||||
if ((misEnableState === true)&&isRightfulPrefix(searchContent)) {
|
||||
// 如果检索内容模糊判断是一个前缀,且mis同步是开着的
|
||||
// alert("成功加载mis的IP: "+misHost+"; misPrefix: "+misPrefix);
|
||||
var host = misHost;
|
||||
// Connect to the forwarder with a WebSocket.
|
||||
@@ -641,6 +661,7 @@ function handleRedirect(details) {
|
||||
return redirect(details);
|
||||
}
|
||||
}, function (interest) {
|
||||
// alert("time out...");
|
||||
// mis系统崩溃,没有给任何应答,直接执行重定向操作
|
||||
if (_redirect_promise_supported) {
|
||||
var promise = new Promise(function (resolve, reject) {
|
||||
@@ -653,6 +674,7 @@ function handleRedirect(details) {
|
||||
}
|
||||
});
|
||||
}else{
|
||||
// 直接尝试重定向
|
||||
if (_redirect_promise_supported) {
|
||||
var promise = new Promise(function (resolve, reject) {
|
||||
var blockingResponse = redirect(details);
|
||||
@@ -665,7 +687,7 @@ function handleRedirect(details) {
|
||||
}
|
||||
}else{
|
||||
// 如果不是进行搜索,且本地没有命中映射表,则异步请求mis更新映射表
|
||||
if(misEnableState===true){
|
||||
if((misEnableState===true)&&isRightfulPrefix(cutHeadString)){
|
||||
updateStorageBasedUri(details.url);
|
||||
}
|
||||
// 并进行重定向
|
||||
|
||||
@@ -11,7 +11,7 @@ function Rule() {
|
||||
this.types = []; // Resource types
|
||||
this.target = null; // Target url pattern
|
||||
this.example = null; // An Test example
|
||||
this.enable = true; // Enable or not
|
||||
this.enable = false; // Enable or not
|
||||
this.process = null; // Process match, urlEncode / urlDecode / base64Encode / base64Decode
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user