Mercurial > urweb
comparison src/c/urweb.c @ 1457:aa2398e58306
Escape less-than in JavaScript strings
author | Adam Chlipala <adam@chlipala.net> |
---|---|
date | Thu, 12 May 2011 17:14:13 -0400 |
parents | b6ce8ef0ea88 |
children | fb88d64abec8 |
comparison
equal
deleted
inserted
replaced
1456:d674fb9499c4 | 1457:aa2398e58306 |
---|---|
1378 break; | 1378 break; |
1379 case '\\': | 1379 case '\\': |
1380 strcpy(s2, "\\\\"); | 1380 strcpy(s2, "\\\\"); |
1381 s2 += 2; | 1381 s2 += 2; |
1382 break; | 1382 break; |
1383 case '<': | |
1384 strcpy(s2, "\\074"); | |
1385 s2 += 4; | |
1386 break; | |
1383 default: | 1387 default: |
1384 if (isprint((int)c) || c >= 128) | 1388 if (isprint((int)c) || c >= 128) |
1385 *s2++ = c; | 1389 *s2++ = c; |
1386 else { | 1390 else { |
1387 sprintf(s2, "\\%03o", c); | 1391 sprintf(s2, "\\%03o", c); |
1415 break; | 1419 break; |
1416 case '\\': | 1420 case '\\': |
1417 strcpy(s2, "\\\\"); | 1421 strcpy(s2, "\\\\"); |
1418 s2 += 2; | 1422 s2 += 2; |
1419 break; | 1423 break; |
1424 case '<': | |
1425 strcpy(s2, "\\074"); | |
1426 s2 += 4; | |
1427 break; | |
1420 default: | 1428 default: |
1421 if (isprint((int)c) || c >= 128) | 1429 if (isprint((int)c) || c >= 128) |
1422 *s2++ = c; | 1430 *s2++ = c; |
1423 else { | 1431 else { |
1424 sprintf(s2, "\\%03o", (unsigned char)c); | 1432 sprintf(s2, "\\%03o", (unsigned char)c); |
1448 s2 += 2; | 1456 s2 += 2; |
1449 break; | 1457 break; |
1450 case '\\': | 1458 case '\\': |
1451 strcpy(s2, "\\\\"); | 1459 strcpy(s2, "\\\\"); |
1452 s2 += 2; | 1460 s2 += 2; |
1461 break; | |
1462 case '<': | |
1463 strcpy(s2, "\\074"); | |
1464 s2 += 4; | |
1453 break; | 1465 break; |
1454 default: | 1466 default: |
1455 if (isprint((int)c) || c >= 128) | 1467 if (isprint((int)c) || c >= 128) |
1456 *s2++ = c; | 1468 *s2++ = c; |
1457 else { | 1469 else { |