forked from EVOgeek/Vmeda.Online
		
	Merge pull request #3096 from dpalou/MOBILE-3833
MOBILE-3833 core: Fix substring errors
This commit is contained in:
		
						commit
						cc78598e4c
					
				@ -190,7 +190,7 @@ export class AddonFilterMathJaxLoaderHandlerService extends CoreFilterDefaultHan
 | 
			
		||||
    protected insertSpan(text: string, start: number, end: number): string {
 | 
			
		||||
        return CoreTextUtils.substrReplace(
 | 
			
		||||
            text,
 | 
			
		||||
            '<span class="nolink">' + text.substring(start, end - start + 1) + '</span>',
 | 
			
		||||
            '<span class="nolink">' + text.substring(start, end + 1) + '</span>',
 | 
			
		||||
            start,
 | 
			
		||||
            end - start + 1,
 | 
			
		||||
        );
 | 
			
		||||
 | 
			
		||||
@ -760,7 +760,7 @@ export class AddonModLessonProvider {
 | 
			
		||||
            let ignoreCase = '';
 | 
			
		||||
 | 
			
		||||
            if (useRegExp) {
 | 
			
		||||
                if (expectedAnswer.substring(-2) == '/i') {
 | 
			
		||||
                if (expectedAnswer.slice(-2) == '/i') {
 | 
			
		||||
                    expectedAnswer = expectedAnswer.substring(0, expectedAnswer.length - 2);
 | 
			
		||||
                    ignoreCase = 'i';
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
@ -748,7 +748,7 @@ export class AddonModScormDataModel12 {
 | 
			
		||||
                    const childrenStr = '._children';
 | 
			
		||||
                    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);
 | 
			
		||||
 | 
			
		||||
                        if (this.dataModel[this.scoId][parentModel] !== undefined) {
 | 
			
		||||
@ -756,7 +756,7 @@ export class AddonModScormDataModel12 {
 | 
			
		||||
                        } else {
 | 
			
		||||
                            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);
 | 
			
		||||
 | 
			
		||||
                        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'];
 | 
			
		||||
        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)) {
 | 
			
		||||
            // Seems to be a web, use HTML mimetype.
 | 
			
		||||
            mimetype = 'text/html';
 | 
			
		||||
@ -158,7 +158,7 @@ export class AddonModUrlProvider {
 | 
			
		||||
        const matches = url.match(/\//g);
 | 
			
		||||
        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.
 | 
			
		||||
            return '';
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
@ -123,8 +123,8 @@ export class CoreColors {
 | 
			
		||||
 | 
			
		||||
        return {
 | 
			
		||||
            red: parseInt(color.substring(0, 2), 16),
 | 
			
		||||
            green: parseInt(color.substring(2, 2), 16),
 | 
			
		||||
            blue: parseInt(color.substring(4, 2), 16),
 | 
			
		||||
            green: parseInt(color.substring(2, 4), 16),
 | 
			
		||||
            blue: parseInt(color.substring(4, 6), 16),
 | 
			
		||||
        };
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@ -123,7 +123,7 @@ function readBytes (str, len, escapedString = false) {
 | 
			
		||||
    const isLowSurrogate = code >= 0xdc00 && code <= 0xdfff
 | 
			
		||||
 | 
			
		||||
    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++
 | 
			
		||||
 | 
			
		||||
      // each escaped sequence is 3 characters. Go 2 chars ahead.
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user