Commit f0aa364c authored by Sergey.Konovalov's avatar Sergey.Konovalov

Bug 30990 - Испорченный файл после сохранения некорректной ссылки.

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@66496 954022d7-b5bf-4e40-9824-e11837661b57
parent c2f3d139
......@@ -409,4 +409,7 @@ baseEditorsApi.prototype.asc_undoAllChanges = function() {
// Offline mode
baseEditorsApi.prototype.asc_isOffline = function() {
return false;
};
baseEditorsApi.prototype.asc_getUrlType = function(url) {
return getUrlType(url);
};
\ No newline at end of file
......@@ -617,6 +617,11 @@ var c_oAscCsvDelimiter = {
Comma: 4,
Space: 5
};
var c_oAscUrlType = {
Invalid : 0,
Http: 1,
Email: 2
};
var c_oAscEncodings = [
[ 0, 28596, "ISO-8859-6", "Arabic (ISO 8859-6)" ],
......
......@@ -54,6 +54,15 @@ if (typeof String.prototype.repeat !== 'function') {
};
String.prototype['repeat'] = String.prototype.repeat;
}
// Extend javascript String type
String.prototype.strongMatch = function(regExp){
if (regExp && regExp instanceof RegExp) {
var arr = this.toString().match(regExp);
return !!(arr && arr.length > 0 && arr[0].length == this.length);
}
return false;
};
var g_oZipChanges = null;
var g_sDownloadServiceLocalUrl = "/downloadas";
......@@ -892,8 +901,29 @@ var str_namedRanges = "A-Za-z\u005F\u0080-\u0081\u0083\u0085-\u0087\u0089-\u008A
rx_CommaDef = /^ *[,;] */,
rx_arrayDef = /^\{(([+-]?\d*(\d|\.)\d*([eE][+-]?\d+)?)?(\"((\"\"|[^\"])*)\")?(#NULL!|#DIV\/0!|#VALUE!|#REF!|#NAME\?|#NUM!|#UNSUPPORTED_FUNCTION!|#N\/A|#GETTING_DATA|FALSE|TRUE)?[,;]?)*\}/i,
rx_ControlSymbols = /^ *[\u0000-\u001F\u007F-\u009F] */,
rx_sFuncPref = /_xlfn\./i;
rx_sFuncPref = /_xlfn\./i,
emailRe = /^(mailto:)?([a-z0-9\._-]+@[a-z0-9\.-]+\.[a-z]{2,4})([a-яё0-9\._%+-=\? :&]*)/i,
ipRe = /^(((https?)|(ftps?)):\/\/)?([\-\wа-яё]*:?[\-\wа-яё]*@)?(((1[0-9]{2}|2[0-4][0-9]|25[0-5]|[1-9][0-9]|[0-9])\.){3}(1[0-9]{2}|2[0-4][0-9]|25[0-5]|[1-9][0-9]|[0-9]))(:\d+)?(\/[%\-\wа-яё]*(\.[\wа-яё]{2,})?(([\wа-яё\-\.\?\\\/+@&#;`~=%!,]*)(\.[\wа-яё]{2,})?)*)*\/?/i,
hostnameRe = /^(((https?)|(ftps?)):\/\/)?([\-\wа-яё]*:?[\-\wа-яё]*@)?(([\-\wа-яё]+\.)+[\wа-яё\-]{2,}(:\d+)?(\/[%\-\wа-яё]*(\.[\wа-яё]{2,})?(([\wа-яё\-\.\?\\\/+@&#;`~=%!,]*)(\.[\wа-яё]{2,})?)*)*\/?)/i,
localRe = /^(((https?)|(ftps?)):\/\/)([\-\wа-яё]*:?[\-\wа-яё]*@)?(([\-\wа-яё]+)(:\d+)?(\/[%\-\wа-яё]*(\.[\wа-яё]{2,})?(([\wа-яё\-\.\?\\\/+@&#;`~=%!,]*)(\.[\wа-яё]{2,})?)*)*\/?)/i;
function getUrlType(url) {
var checkvalue = url.replace(new RegExp(' ', 'g'), '%20');
var isEmail = false;
var isvalid = checkvalue.strongMatch(hostnameRe);
!isvalid && (isEmail = isvalid = checkvalue.strongMatch(emailRe));
!isvalid && (isvalid = checkvalue.strongMatch(ipRe));
!isvalid && (isvalid = checkvalue.strongMatch(localRe));
return isvalid ? (isEmail ? c_oAscUrlType.Email : c_oAscUrlType.Http) : c_oAscUrlType.Invalid;
}
function prepareUrl(url, type) {
if (!/(((^https?)|(^ftp)):\/\/)|(^mailto:)/i.test(url)) {
url = ( (c_oAscUrlType.Email == type) ? 'mailto:' : 'http://' ) + url;
}
return url.replace(new RegExp("%20", 'g'), " ");
}
/**
* вспомогательный объект для парсинга формул и проверки строки по регуляркам указанным выше.
......
......@@ -3434,4 +3434,5 @@ var editor;
prot["asc_nativeGetPDF"] = prot.asc_nativeGetPDF;
prot['asc_isOffline'] = prot.asc_isOffline;
prot['asc_getUrlType'] = prot.asc_getUrlType;
})(jQuery, window);
......@@ -3252,22 +3252,16 @@ CCellValue.prototype =
}
}
}
if (0 == val.indexOf("http://") || 0 == val.indexOf("https://") || (0 == val.indexOf("www.") && val.length > 4)) {
// Удаляем концевые пробелы и
var endIndex = val.length - 1;
while (0 < endIndex && ('\n' === val[endIndex] || ' ' === val[endIndex])) {
--endIndex;
}
var sRealUrl = val.slice(0, endIndex + 1);
if (-1 === sRealUrl.indexOf('\n')) {
if (0 != val.indexOf("http://") && 0 != val.indexOf("https://")) {
sRealUrl = "http://" + sRealUrl;
}
var oNewHyperlink = new Hyperlink();
oNewHyperlink.Ref = cell.ws.getCell3(cell.nRow, cell.nCol);
oNewHyperlink.Hyperlink = encodeURI(sRealUrl);
oNewHyperlink.Ref.setHyperlink(oNewHyperlink);
}
// Удаляем концевые пробелы и переводы строки перед проверкой гиперссылок
val = val.replace(/\s+$/, '');
var typeHyp = getUrlType(val);
if (c_oAscUrlType.Invalid != typeHyp) {
val = prepareUrl(val, typeHyp);
var oNewHyperlink = new Hyperlink();
oNewHyperlink.Ref = cell.ws.getCell3(cell.nRow, cell.nCol);
oNewHyperlink.Hyperlink = val;
oNewHyperlink.Ref.setHyperlink(oNewHyperlink);
}
},
setValue2 : function(cell, aVal)
......
......@@ -404,6 +404,7 @@ asc_docs_api.prototype['sync_ContextMenuCallback'] = asc_docs_api.prototype.sync
asc_docs_api.prototype['asc_addComment'] = asc_docs_api.prototype.asc_addComment;
asc_docs_api.prototype['asc_SetFastCollaborative'] = asc_docs_api.prototype.asc_SetFastCollaborative;
asc_docs_api.prototype['asc_isOffline'] = asc_docs_api.prototype.asc_isOffline;
asc_docs_api.prototype['asc_getUrlType'] = asc_docs_api.prototype.asc_getUrlType;
window['OnSave_Callback'] = OnSave_Callback;
window['asc_CCommentData'] = asc_CCommentData;
asc_CCommentData.prototype['asc_getText'] = asc_CCommentData.prototype.asc_getText;
......
......@@ -532,6 +532,7 @@ asc_docs_api.prototype['asc_CloseFile'] = asc_docs_api.prototype.asc_CloseFile;
asc_docs_api.prototype['asc_addComment'] = asc_docs_api.prototype.asc_addComment;
asc_docs_api.prototype['asc_SetFastCollaborative'] = asc_docs_api.prototype.asc_SetFastCollaborative;
asc_docs_api.prototype['asc_isOffline'] = asc_docs_api.prototype.asc_isOffline;
asc_docs_api.prototype['asc_getUrlType'] = asc_docs_api.prototype.asc_getUrlType;
window['CMathProp'] = CMathProp;
CMathProp.prototype['get_Type'] = CMathProp.prototype.get_Type;
window['CParagraphPropEx'] = CParagraphPropEx;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment