MOBILE-3833 core: Fix substring errors
parent
947534a6b7
commit
a6df4e997b
|
@ -190,7 +190,7 @@ export class AddonFilterMathJaxLoaderHandlerService extends CoreFilterDefaultHan
|
||||||
protected insertSpan(text: string, start: number, end: number): string {
|
protected insertSpan(text: string, start: number, end: number): string {
|
||||||
return CoreTextUtils.substrReplace(
|
return CoreTextUtils.substrReplace(
|
||||||
text,
|
text,
|
||||||
'<span class="nolink">' + text.substring(start, end - start + 1) + '</span>',
|
'<span class="nolink">' + text.substring(start, end + 1) + '</span>',
|
||||||
start,
|
start,
|
||||||
end - start + 1,
|
end - start + 1,
|
||||||
);
|
);
|
||||||
|
|
|
@ -760,7 +760,7 @@ export class AddonModLessonProvider {
|
||||||
let ignoreCase = '';
|
let ignoreCase = '';
|
||||||
|
|
||||||
if (useRegExp) {
|
if (useRegExp) {
|
||||||
if (expectedAnswer.substring(-2) == '/i') {
|
if (expectedAnswer.slice(-2) == '/i') {
|
||||||
expectedAnswer = expectedAnswer.substring(0, expectedAnswer.length - 2);
|
expectedAnswer = expectedAnswer.substring(0, expectedAnswer.length - 2);
|
||||||
ignoreCase = 'i';
|
ignoreCase = 'i';
|
||||||
}
|
}
|
||||||
|
|
|
@ -748,7 +748,7 @@ export class AddonModScormDataModel12 {
|
||||||
const childrenStr = '._children';
|
const childrenStr = '._children';
|
||||||
const countStr = '._count';
|
const countStr = '._count';
|
||||||
|
|
||||||
if (elementModel.substring(elementModel.length - childrenStr.length, elementModel.length) == childrenStr) {
|
if (elementModel.substring(elementModel.length - childrenStr.length) == childrenStr) {
|
||||||
const parentModel = elementModel.substring(0, elementModel.length - childrenStr.length);
|
const parentModel = elementModel.substring(0, elementModel.length - childrenStr.length);
|
||||||
|
|
||||||
if (this.dataModel[this.scoId][parentModel] !== undefined) {
|
if (this.dataModel[this.scoId][parentModel] !== undefined) {
|
||||||
|
@ -756,7 +756,7 @@ export class AddonModScormDataModel12 {
|
||||||
} else {
|
} else {
|
||||||
this.errorCode = '201';
|
this.errorCode = '201';
|
||||||
}
|
}
|
||||||
} else if (elementModel.substring(elementModel.length - countStr.length, elementModel.length) == countStr) {
|
} else if (elementModel.substring(elementModel.length - countStr.length) == countStr) {
|
||||||
const parentModel = elementModel.substring(0, elementModel.length - countStr.length);
|
const parentModel = elementModel.substring(0, elementModel.length - countStr.length);
|
||||||
|
|
||||||
if (this.dataModel[this.scoId][parentModel] !== undefined) {
|
if (this.dataModel[this.scoId][parentModel] !== undefined) {
|
||||||
|
|
|
@ -68,7 +68,7 @@ export class AddonModUrlProvider {
|
||||||
const download = ['application/zip', 'application/x-tar', 'application/g-zip', 'application/pdf', 'text/html'];
|
const download = ['application/zip', 'application/x-tar', 'application/g-zip', 'application/pdf', 'text/html'];
|
||||||
let mimetype = CoreMimetypeUtils.getMimeType(extension);
|
let mimetype = CoreMimetypeUtils.getMimeType(extension);
|
||||||
|
|
||||||
if (url.externalurl.indexOf('.php') != -1 || url.externalurl.substring(-1) === '/' ||
|
if (url.externalurl.indexOf('.php') != -1 || url.externalurl.slice(-1) === '/' ||
|
||||||
(url.externalurl.indexOf('//') != -1 && url.externalurl.match(/\//g)?.length == 2)) {
|
(url.externalurl.indexOf('//') != -1 && url.externalurl.match(/\//g)?.length == 2)) {
|
||||||
// Seems to be a web, use HTML mimetype.
|
// Seems to be a web, use HTML mimetype.
|
||||||
mimetype = 'text/html';
|
mimetype = 'text/html';
|
||||||
|
@ -158,7 +158,7 @@ export class AddonModUrlProvider {
|
||||||
const matches = url.match(/\//g);
|
const matches = url.match(/\//g);
|
||||||
const extension = CoreMimetypeUtils.getFileExtension(url);
|
const extension = CoreMimetypeUtils.getFileExtension(url);
|
||||||
|
|
||||||
if (!matches || matches.length < 3 || url.substring(-1) === '/' || extension == 'php') {
|
if (!matches || matches.length < 3 || url.slice(-1) === '/' || extension == 'php') {
|
||||||
// Use default icon.
|
// Use default icon.
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
|
@ -123,8 +123,8 @@ export class CoreColors {
|
||||||
|
|
||||||
return {
|
return {
|
||||||
red: parseInt(color.substring(0, 2), 16),
|
red: parseInt(color.substring(0, 2), 16),
|
||||||
green: parseInt(color.substring(2, 2), 16),
|
green: parseInt(color.substring(2, 4), 16),
|
||||||
blue: parseInt(color.substring(4, 2), 16),
|
blue: parseInt(color.substring(4, 6), 16),
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -123,7 +123,7 @@ function readBytes (str, len, escapedString = false) {
|
||||||
const isLowSurrogate = code >= 0xdc00 && code <= 0xdfff
|
const isLowSurrogate = code >= 0xdc00 && code <= 0xdfff
|
||||||
|
|
||||||
if (escapedString && chr === '\\') {
|
if (escapedString && chr === '\\') {
|
||||||
chr = String.fromCharCode(parseInt(str.substring(c + 1, 2), 16))
|
chr = String.fromCharCode(parseInt(str.substring(c + 1, c + 3), 16))
|
||||||
escapedChars++
|
escapedChars++
|
||||||
|
|
||||||
// each escaped sequence is 3 characters. Go 2 chars ahead.
|
// each escaped sequence is 3 characters. Go 2 chars ahead.
|
||||||
|
|
Loading…
Reference in New Issue