Subversion Repositories Kolibri OS

Rev

Rev 7091 | Rev 7296 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 7091 Rev 7101
Line 1294... Line 1294...
1294
        pusha
1294
        pusha
Line 1295... Line 1295...
1295
 
1295
 
1296
        invoke  mem.alloc, URLMAXLEN            ; FIXME: use length provided by caller to guess final size.
1296
        invoke  mem.alloc, URLMAXLEN            ; FIXME: use length provided by caller to guess final size.
1297
        test    eax, eax
1297
        test    eax, eax
-
 
1298
        jz      .error
1298
        jz      .error
1299
        mov     edx, URLMAXLEN-1                ; Remaining space in temp buffer minus one for 0 byte
1299
        mov     [esp + 7 * 4], eax              ; return ptr in eax
1300
        mov     [esp + 7 * 4], eax              ; return ptr in eax
1300
        mov     esi, [URI]
1301
        mov     esi, [URI]
1301
        mov     edi, eax
1302
        mov     edi, eax
1302
        xor     ebx, ebx
1303
        xor     ebx, ebx
Line 1313... Line 1314...
1313
        and     bl, not 3
1314
        and     bl, not 3
1314
        bt      dword[bits_must_escape + ebx], ecx
1315
        bt      dword[bits_must_escape + ebx], ecx
1315
        jc      .escape
1316
        jc      .escape
Line 1316... Line 1317...
1316
 
1317
 
-
 
1318
        stosb
1317
        stosb
1319
        dec     edx
-
 
1320
        jnz     .loop
Line 1318... Line 1321...
1318
        jmp     .loop
1321
        jmp     .out_of_space
-
 
1322
 
-
 
1323
  .escape:
1319
 
1324
        sub     edx, 3
1320
  .escape:
1325
        jbe     .out_of_space
1321
        mov     al, '%'
1326
        mov     al, '%'
1322
        stosb
1327
        stosb
1323
        mov     bl, byte[esi-1]
1328
        mov     bl, byte[esi-1]
Line 1329... Line 1334...
1329
        mov     al, byte[str_hex + ebx]
1334
        mov     al, byte[str_hex + ebx]
1330
        stosb
1335
        stosb
1331
        jmp     .loop
1336
        jmp     .loop
Line -... Line 1337...
-
 
1337
 
-
 
1338
 
-
 
1339
  .out_of_space:
1332
 
1340
        DEBUGF  2, "ERROR: buffer too small!\n"
-
 
1341
 
1333
 
1342
  .done:
1334
  .done:
1343
        xor     al, al
1335
        stosb
1344
        stosb
1336
        sub     edi, [esp + 7 * 4]
1345
        sub     edi, [esp + 7 * 4]
Line 1365... Line 1374...
1365
        pusha
1374
        pusha
Line 1366... Line 1375...
1366
 
1375
 
1367
        invoke  mem.alloc, URLMAXLEN            ; FIXME: use length provided by caller
1376
        invoke  mem.alloc, URLMAXLEN            ; FIXME: use length provided by caller
1368
        test    eax, eax
1377
        test    eax, eax
-
 
1378
        jz      .error
1369
        jz      .error
1379
        mov     edx, URLMAXLEN-1                ; Remaining space in temp buffer minus one for 0 byte
1370
        mov     [esp + 7 * 4], eax              ; return ptr in eax
1380
        mov     [esp + 7 * 4], eax              ; return ptr in eax
1371
        mov     esi, [URI]
1381
        mov     esi, [URI]
1372
        mov     edi, eax
1382
        mov     edi, eax
1373
  .loop:
1383
  .loop:
1374
        lodsb
1384
        lodsb
1375
        test    al, al
1385
        test    al, al
1376
        jz      .done
1386
        jz      .done
1377
        cmp     al, '%'
1387
        cmp     al, '%'
1378
        je      .unescape
1388
        je      .unescape
-
 
1389
        stosb
1379
        stosb
1390
        dec     edx
-
 
1391
        jnz     .loop
Line 1380... Line 1392...
1380
        jmp     .loop
1392
        jmp     .out_of_space
1381
 
1393
 
1382
  .unescape:
1394
  .unescape:
1383
        xor     ebx, ebx
1395
        xor     ebx, ebx
Line 1400... Line 1412...
1400
        or      bl, al
1412
        or      bl, al
1401
        dec     ecx
1413
        dec     ecx
1402
        jc      .unescape_nibble
1414
        jc      .unescape_nibble
1403
        mov     al, bl
1415
        mov     al, bl
1404
        stosb
1416
        stosb
-
 
1417
        dec     edx
1405
        jmp     .loop
1418
        jnz     .loop
-
 
1419
        jmp     .out_of_space
Line 1406... Line 1420...
1406
 
1420
 
1407
  .fail:
1421
  .fail:
1408
        DEBUGF  2, "ERROR: invalid URI!\n"
1422
        DEBUGF  2, "ERROR: invalid URI!\n"
Line -... Line 1423...
-
 
1423
        jmp     .loop
-
 
1424
 
-
 
1425
  .out_of_space:
1409
        jmp     .loop
1426
        DEBUGF  2, "ERROR: buffer too small!\n"
-
 
1427
 
1410
 
1428
  .done:
1411
  .done:
1429
        xor     al, al
1412
        stosb
1430
        stosb
1413
        popa
1431
        popa