/ Check-in [ce1f147224]
DEMO | DOWNLOAD | DEPLOY | SEARCH
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Release "2.8.30". Handle JSON.parse of embedded null. Fix indexing into blob-string with embedded null. Reject utf null code literal.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:ce1f147224f5909802357d4769e4bae2287df33e
User & Date: pmacdona 2019-05-22 22:14:04
References
2019-05-22
22:23 Ticket [f8d3a82011] NUL bytes not encodable status still Open with 3 other changes artifact: 7aa14f143a user: pmacdona
Context
2019-05-23
04:15
Release "2.8.31". Fix parser bug in strings with line ending in backslash. check-in: 10502f4b73 user: pmacdona tags: trunk
2019-05-22
22:14
Release "2.8.30". Handle JSON.parse of embedded null. Fix indexing into blob-string with embedded null. Reject utf null code literal. check-in: ce1f147224 user: pmacdona tags: trunk
2019-05-21
14:05
Release "2.8.29". Fix length bug in non-zStr handling, eg. chan.read(N). check-in: 8c05719e99 user: pmacdona tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/jsi.c.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
.....
16080
16081
16082
16083
16084
16085
16086
16087





16088
16089
16090
16091
16092
16093
16094
16095
16096
.....
19049
19050
19051
19052
19053
19054
19055

19056
19057
19058
19059
19060
19061
19062
.....
19275
19276
19277
19278
19279
19280
19281
19282
19283
19284
19285
19286
19287
19288
19289
.....
33675
33676
33677
33678
33679
33680
33681

33682
33683
33684
33685
33686
33687
33688
33689
33690
33691
33692
33693
33694
33695
33696

33697
33698
33699
33700
33701
33702
33703
33704
.....
46190
46191
46192
46193
46194
46195
46196
46197
46198
46199
46200
46201
46202
46203
46204
.....
69250
69251
69252
69253
69254
69255
69256
69257
69258
69259
69260
69261
69262
69263
69264
/* jsi.h : External API header file for Jsi. */
#ifndef __JSI_H__
#define __JSI_H__

#define JSI_VERSION_MAJOR   2
#define JSI_VERSION_MINOR   8
#define JSI_VERSION_RELEASE 29

#define JSI_VERSION (JSI_VERSION_MAJOR + ((Jsi_Number)JSI_VERSION_MINOR/100.0) + ((Jsi_Number)JSI_VERSION_RELEASE/10000.0))

#ifndef JSI_EXTERN
#define JSI_EXTERN extern
#endif

................................................................................
                case 'u': {
                    char ibuf[5];
                    int ui;
                    for (ui=0; ui<4; ui++)
                        ibuf[ui] = lexer_getchar(lex);
                    ibuf[4] = 0;
                    ui = Jsi_UtfDecode(ibuf, buf+bufi);
                    if (ui>0)





                        bufi+=ui;
                    else {
                        Jsi_LogError("Unexpected utf encoding.");
                        buf[bufi++] = 0;
                        goto done;
                    }
                    break;
                }
                case EOF: 
................................................................................
        v = Jsi_ValueNew(interp);
    else
        Jsi_ValueReset(interp, vPtr);
    Jsi_Obj *obj = Jsi_ObjNewType(interp, JSI_OT_STRING);
    Jsi_ValueMakeObject(interp, &v, obj);
    obj->d.s.str = (char*)s;
    obj->d.s.len = len;

    return v;
}


Jsi_Value* Jsi_ValueMakeString(Jsi_Interp *interp, Jsi_Value **vPtr, const char *s) {
    return Jsi_ValueMakeBlob(interp, vPtr, (unsigned char *)s, Jsi_Strlen(s));
}
................................................................................
    dsPtr->strA = NULL;
    dsPtr->Str[0] = 0;
    dsPtr->len = 0;
    dsPtr->spaceAvl = dsPtr->staticSize;
    if (!cp)
        Jsi_ValueMakeStringDup(interp, ret, "");
    else
        Jsi_ValueMakeString(interp, ret, cp);
}

#endif
#ifndef JSI_LITE_ONLY
#ifndef JSI_AMALGAMATION
#include "jsiInt.h"
#endif
................................................................................
            }
            cp+=2;
        } else {
            *dp++ = *cp++;
        }
        if ((dp-buf)>90) {
            *dp = 0;

            dp = buf;
            Jsi_DSAppend(dStr, buf, NULL);
        }
    }
    *dp = 0;
    Jsi_DSAppend(dStr, buf, NULL);
}

static Jsi_Value *jsonNewStringObj(Jsi_Interp *interp, const char* str, int len)
{
    Jsi_Value *v = NULL;
    Jsi_DString dStr;
    Jsi_DSInit(&dStr);
    jsonNewDString(interp, &dStr, str, len);
    v = Jsi_ValueMakeStringDup(interp, NULL, Jsi_DSValue(&dStr));

    Jsi_DSFree(&dStr);
    return v;
}

static Jsi_Value* jsonGenObject(Jsi_Interp *interp, Jsi_JsonParser *p, const char *js, uint pos, uint *endPos);
static Jsi_Value* jsonGenArray(Jsi_Interp *interp, Jsi_JsonParser *p, const char *js, uint pos, uint *endPos);

static Jsi_Value*
................................................................................
    if (length<0) {
        while (*s)
            if ((*s++ & 0xc0) != 0x80)
                i++;
        return i;
    }
    const char *so = s;
    while (*s) {
        if ((*s++ & 0xc0) != 0x80)
            i++;
        if ((s-so)>=length)
            break;
    }
    return i;
#endif
................................................................................
    if (str && Jsi_ValueIsNumber(interp, idx)) {
        int bLen, cLen;
        char bbuf[10], *cp = Jsi_ValueString(interp, src, &bLen);
        int n = (int)idx->d.num;
        cLen = bLen;
#if JSI__UTF8
        if (str->flags&JSI_IS_UTF || !(str->flags&JSI_UTF_CHECKED)) {
            cLen = Jsi_NumUtfChars(cp, -1);
            str->flags |= JSI_UTF_CHECKED;
            if (cLen != bLen)
                str->flags |= JSI_IS_UTF;
        }
#endif
        if (n<0 || n>=cLen) {
            Jsi_ValueMakeUndef(interp, &src);






|







 







|
>
>
>
>
>

|







 







>







 







|







 







>

<



|








|
>
|







 







|







 







|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
.....
16080
16081
16082
16083
16084
16085
16086
16087
16088
16089
16090
16091
16092
16093
16094
16095
16096
16097
16098
16099
16100
16101
.....
19054
19055
19056
19057
19058
19059
19060
19061
19062
19063
19064
19065
19066
19067
19068
.....
19281
19282
19283
19284
19285
19286
19287
19288
19289
19290
19291
19292
19293
19294
19295
.....
33681
33682
33683
33684
33685
33686
33687
33688
33689

33690
33691
33692
33693
33694
33695
33696
33697
33698
33699
33700
33701
33702
33703
33704
33705
33706
33707
33708
33709
33710
33711
.....
46197
46198
46199
46200
46201
46202
46203
46204
46205
46206
46207
46208
46209
46210
46211
.....
69257
69258
69259
69260
69261
69262
69263
69264
69265
69266
69267
69268
69269
69270
69271
/* jsi.h : External API header file for Jsi. */
#ifndef __JSI_H__
#define __JSI_H__

#define JSI_VERSION_MAJOR   2
#define JSI_VERSION_MINOR   8
#define JSI_VERSION_RELEASE 30

#define JSI_VERSION (JSI_VERSION_MAJOR + ((Jsi_Number)JSI_VERSION_MINOR/100.0) + ((Jsi_Number)JSI_VERSION_RELEASE/10000.0))

#ifndef JSI_EXTERN
#define JSI_EXTERN extern
#endif

................................................................................
                case 'u': {
                    char ibuf[5];
                    int ui;
                    for (ui=0; ui<4; ui++)
                        ibuf[ui] = lexer_getchar(lex);
                    ibuf[4] = 0;
                    ui = Jsi_UtfDecode(ibuf, buf+bufi);
                    if (ui>0) {
                        if (!buf[bufi]) {
                            Jsi_LogError("code literal utf null unsupported (u0000)");
                            buf[bufi++] = 0;
                            goto done;
                        }
                        bufi+=ui;
                    } else {
                        Jsi_LogError("Unexpected utf encoding.");
                        buf[bufi++] = 0;
                        goto done;
                    }
                    break;
                }
                case EOF: 
................................................................................
        v = Jsi_ValueNew(interp);
    else
        Jsi_ValueReset(interp, vPtr);
    Jsi_Obj *obj = Jsi_ObjNewType(interp, JSI_OT_STRING);
    Jsi_ValueMakeObject(interp, &v, obj);
    obj->d.s.str = (char*)s;
    obj->d.s.len = len;
    obj->isBlob = 1;
    return v;
}


Jsi_Value* Jsi_ValueMakeString(Jsi_Interp *interp, Jsi_Value **vPtr, const char *s) {
    return Jsi_ValueMakeBlob(interp, vPtr, (unsigned char *)s, Jsi_Strlen(s));
}
................................................................................
    dsPtr->strA = NULL;
    dsPtr->Str[0] = 0;
    dsPtr->len = 0;
    dsPtr->spaceAvl = dsPtr->staticSize;
    if (!cp)
        Jsi_ValueMakeStringDup(interp, ret, "");
    else
        Jsi_ValueMakeBlob(interp, ret, (uchar*)cp, len);
}

#endif
#ifndef JSI_LITE_ONLY
#ifndef JSI_AMALGAMATION
#include "jsiInt.h"
#endif
................................................................................
            }
            cp+=2;
        } else {
            *dp++ = *cp++;
        }
        if ((dp-buf)>90) {
            *dp = 0;
            Jsi_DSAppendLen(dStr, buf, dp-buf);
            dp = buf;

        }
    }
    *dp = 0;
    Jsi_DSAppendLen(dStr, buf, dp-buf);
}

static Jsi_Value *jsonNewStringObj(Jsi_Interp *interp, const char* str, int len)
{
    Jsi_Value *v = NULL;
    Jsi_DString dStr;
    Jsi_DSInit(&dStr);
    jsonNewDString(interp, &dStr, str, len);
    v = Jsi_ValueNew(interp);
    Jsi_ValueFromDS(interp, &dStr, &v);
    //Jsi_DSFree(&dStr);
    return v;
}

static Jsi_Value* jsonGenObject(Jsi_Interp *interp, Jsi_JsonParser *p, const char *js, uint pos, uint *endPos);
static Jsi_Value* jsonGenArray(Jsi_Interp *interp, Jsi_JsonParser *p, const char *js, uint pos, uint *endPos);

static Jsi_Value*
................................................................................
    if (length<0) {
        while (*s)
            if ((*s++ & 0xc0) != 0x80)
                i++;
        return i;
    }
    const char *so = s;
    while (1) {
        if ((*s++ & 0xc0) != 0x80)
            i++;
        if ((s-so)>=length)
            break;
    }
    return i;
#endif
................................................................................
    if (str && Jsi_ValueIsNumber(interp, idx)) {
        int bLen, cLen;
        char bbuf[10], *cp = Jsi_ValueString(interp, src, &bLen);
        int n = (int)idx->d.num;
        cLen = bLen;
#if JSI__UTF8
        if (str->flags&JSI_IS_UTF || !(str->flags&JSI_UTF_CHECKED)) {
            cLen = Jsi_NumUtfChars(cp, bLen);
            str->flags |= JSI_UTF_CHECKED;
            if (cLen != bLen)
                str->flags |= JSI_IS_UTF;
        }
#endif
        if (n<0 || n>=cLen) {
            Jsi_ValueMakeUndef(interp, &src);

Changes to src/jsi.h.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
/* jsi.h : External API header file for Jsi. */
#ifndef __JSI_H__
#define __JSI_H__

#define JSI_VERSION_MAJOR   2
#define JSI_VERSION_MINOR   8
#define JSI_VERSION_RELEASE 29

#define JSI_VERSION (JSI_VERSION_MAJOR + ((Jsi_Number)JSI_VERSION_MINOR/100.0) + ((Jsi_Number)JSI_VERSION_RELEASE/10000.0))

#ifndef JSI_EXTERN
#define JSI_EXTERN extern
#endif







|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
/* jsi.h : External API header file for Jsi. */
#ifndef __JSI_H__
#define __JSI_H__

#define JSI_VERSION_MAJOR   2
#define JSI_VERSION_MINOR   8
#define JSI_VERSION_RELEASE 30

#define JSI_VERSION (JSI_VERSION_MAJOR + ((Jsi_Number)JSI_VERSION_MINOR/100.0) + ((Jsi_Number)JSI_VERSION_RELEASE/10000.0))

#ifndef JSI_EXTERN
#define JSI_EXTERN extern
#endif

Changes to src/jsiEval.c.

1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
    if (str && Jsi_ValueIsNumber(interp, idx)) {
        int bLen, cLen;
        char bbuf[10], *cp = Jsi_ValueString(interp, src, &bLen);
        int n = (int)idx->d.num;
        cLen = bLen;
#if JSI__UTF8
        if (str->flags&JSI_IS_UTF || !(str->flags&JSI_UTF_CHECKED)) {
            cLen = Jsi_NumUtfChars(cp, -1);
            str->flags |= JSI_UTF_CHECKED;
            if (cLen != bLen)
                str->flags |= JSI_IS_UTF;
        }
#endif
        if (n<0 || n>=cLen) {
            Jsi_ValueMakeUndef(interp, &src);







|







1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
    if (str && Jsi_ValueIsNumber(interp, idx)) {
        int bLen, cLen;
        char bbuf[10], *cp = Jsi_ValueString(interp, src, &bLen);
        int n = (int)idx->d.num;
        cLen = bLen;
#if JSI__UTF8
        if (str->flags&JSI_IS_UTF || !(str->flags&JSI_UTF_CHECKED)) {
            cLen = Jsi_NumUtfChars(cp, bLen);
            str->flags |= JSI_UTF_CHECKED;
            if (cLen != bLen)
                str->flags |= JSI_IS_UTF;
        }
#endif
        if (n<0 || n>=cLen) {
            Jsi_ValueMakeUndef(interp, &src);

Changes to src/jsiJSON.c.

32
33
34
35
36
37
38

39
40
41
42
43
44
45
46
47
48
49
50
51
52
53

54
55
56
57
58
59
60
61
            }
            cp+=2;
        } else {
            *dp++ = *cp++;
        }
        if ((dp-buf)>90) {
            *dp = 0;

            dp = buf;
            Jsi_DSAppend(dStr, buf, NULL);
        }
    }
    *dp = 0;
    Jsi_DSAppend(dStr, buf, NULL);
}

static Jsi_Value *jsonNewStringObj(Jsi_Interp *interp, const char* str, int len)
{
    Jsi_Value *v = NULL;
    Jsi_DString dStr;
    Jsi_DSInit(&dStr);
    jsonNewDString(interp, &dStr, str, len);
    v = Jsi_ValueMakeStringDup(interp, NULL, Jsi_DSValue(&dStr));

    Jsi_DSFree(&dStr);
    return v;
}

static Jsi_Value* jsonGenObject(Jsi_Interp *interp, Jsi_JsonParser *p, const char *js, uint pos, uint *endPos);
static Jsi_Value* jsonGenArray(Jsi_Interp *interp, Jsi_JsonParser *p, const char *js, uint pos, uint *endPos);

static Jsi_Value*







>

<



|








|
>
|







32
33
34
35
36
37
38
39
40

41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
            }
            cp+=2;
        } else {
            *dp++ = *cp++;
        }
        if ((dp-buf)>90) {
            *dp = 0;
            Jsi_DSAppendLen(dStr, buf, dp-buf);
            dp = buf;

        }
    }
    *dp = 0;
    Jsi_DSAppendLen(dStr, buf, dp-buf);
}

static Jsi_Value *jsonNewStringObj(Jsi_Interp *interp, const char* str, int len)
{
    Jsi_Value *v = NULL;
    Jsi_DString dStr;
    Jsi_DSInit(&dStr);
    jsonNewDString(interp, &dStr, str, len);
    v = Jsi_ValueNew(interp);
    Jsi_ValueFromDS(interp, &dStr, &v);
    //Jsi_DSFree(&dStr);
    return v;
}

static Jsi_Value* jsonGenObject(Jsi_Interp *interp, Jsi_JsonParser *p, const char *js, uint pos, uint *endPos);
static Jsi_Value* jsonGenArray(Jsi_Interp *interp, Jsi_JsonParser *p, const char *js, uint pos, uint *endPos);

static Jsi_Value*

Changes to src/jsiLexer.c.

160
161
162
163
164
165
166
167





168
169
170
171
172
173
174
175
176
                case 'u': {
                    char ibuf[5];
                    int ui;
                    for (ui=0; ui<4; ui++)
                        ibuf[ui] = lexer_getchar(lex);
                    ibuf[4] = 0;
                    ui = Jsi_UtfDecode(ibuf, buf+bufi);
                    if (ui>0)





                        bufi+=ui;
                    else {
                        Jsi_LogError("Unexpected utf encoding.");
                        buf[bufi++] = 0;
                        goto done;
                    }
                    break;
                }
                case EOF: 







|
>
>
>
>
>

|







160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
                case 'u': {
                    char ibuf[5];
                    int ui;
                    for (ui=0; ui<4; ui++)
                        ibuf[ui] = lexer_getchar(lex);
                    ibuf[4] = 0;
                    ui = Jsi_UtfDecode(ibuf, buf+bufi);
                    if (ui>0) {
                        if (!buf[bufi]) {
                            Jsi_LogError("code literal utf null unsupported (u0000)");
                            buf[bufi++] = 0;
                            goto done;
                        }
                        bufi+=ui;
                    } else {
                        Jsi_LogError("Unexpected utf encoding.");
                        buf[bufi++] = 0;
                        goto done;
                    }
                    break;
                }
                case EOF: 

Changes to src/jsiUtf8.c.

57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
    if (length<0) {
        while (*s)
            if ((*s++ & 0xc0) != 0x80)
                i++;
        return i;
    }
    const char *so = s;
    while (*s) {
        if ((*s++ & 0xc0) != 0x80)
            i++;
        if ((s-so)>=length)
            break;
    }
    return i;
#endif







|







57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
    if (length<0) {
        while (*s)
            if ((*s++ & 0xc0) != 0x80)
                i++;
        return i;
    }
    const char *so = s;
    while (1) {
        if ((*s++ & 0xc0) != 0x80)
            i++;
        if ((s-so)>=length)
            break;
    }
    return i;
#endif

Changes to src/jsiValue.c.

1521
1522
1523
1524
1525
1526
1527

1528
1529
1530
1531
1532
1533
1534
....
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
        v = Jsi_ValueNew(interp);
    else
        Jsi_ValueReset(interp, vPtr);
    Jsi_Obj *obj = Jsi_ObjNewType(interp, JSI_OT_STRING);
    Jsi_ValueMakeObject(interp, &v, obj);
    obj->d.s.str = (char*)s;
    obj->d.s.len = len;

    return v;
}


Jsi_Value* Jsi_ValueMakeString(Jsi_Interp *interp, Jsi_Value **vPtr, const char *s) {
    return Jsi_ValueMakeBlob(interp, vPtr, (unsigned char *)s, Jsi_Strlen(s));
}
................................................................................
    dsPtr->strA = NULL;
    dsPtr->Str[0] = 0;
    dsPtr->len = 0;
    dsPtr->spaceAvl = dsPtr->staticSize;
    if (!cp)
        Jsi_ValueMakeStringDup(interp, ret, "");
    else
        Jsi_ValueMakeString(interp, ret, cp);
}

#endif







>







 







|



1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
....
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
        v = Jsi_ValueNew(interp);
    else
        Jsi_ValueReset(interp, vPtr);
    Jsi_Obj *obj = Jsi_ObjNewType(interp, JSI_OT_STRING);
    Jsi_ValueMakeObject(interp, &v, obj);
    obj->d.s.str = (char*)s;
    obj->d.s.len = len;
    obj->isBlob = 1;
    return v;
}


Jsi_Value* Jsi_ValueMakeString(Jsi_Interp *interp, Jsi_Value **vPtr, const char *s) {
    return Jsi_ValueMakeBlob(interp, vPtr, (unsigned char *)s, Jsi_Strlen(s));
}
................................................................................
    dsPtr->strA = NULL;
    dsPtr->Str[0] = 0;
    dsPtr->len = 0;
    dsPtr->spaceAvl = dsPtr->staticSize;
    if (!cp)
        Jsi_ValueMakeStringDup(interp, ret, "");
    else
        Jsi_ValueMakeBlob(interp, ret, (uchar*)cp, len);
}

#endif

Changes to tools/protos.jsi.

1
2
3
4
5
6
7
8
//JSI Command Prototypes: version 2.8.28
throw("NOT EXECUTABLE: USE FILE IN GEANY EDITOR FOR CMD LINE COMPLETION + GOTO TAG");

var Array = function(cmd,args) {};
Array.prototype.concat = function(...):array {};
Array.prototype.every = function(callback:function):any {};
Array.prototype.fill = function(value:any, start:number=0, end:number=-1):array {};
Array.prototype.filter = function(callback:function, this:object=void):array {};
|







1
2
3
4
5
6
7
8
//JSI Command Prototypes: version 2.8.30
throw("NOT EXECUTABLE: USE FILE IN GEANY EDITOR FOR CMD LINE COMPLETION + GOTO TAG");

var Array = function(cmd,args) {};
Array.prototype.concat = function(...):array {};
Array.prototype.every = function(callback:function):any {};
Array.prototype.fill = function(value:any, start:number=0, end:number=-1):array {};
Array.prototype.filter = function(callback:function, this:object=void):array {};