Parse lists as described by RFC 2068 Section 2. In particular, parse comma-separated lists where the elements of the list may include quoted-strings. A quoted-string could contain a comma. A non-quoted string could have quotes in the middle. Neither commas nor quotes count if the
(s)
| 1409 | return parsed |
| 1410 | |
| 1411 | def parse_http_list(s): |
| 1412 | """Parse lists as described by RFC 2068 Section 2. |
| 1413 | |
| 1414 | In particular, parse comma-separated lists where the elements of |
| 1415 | the list may include quoted-strings. A quoted-string could |
| 1416 | contain a comma. A non-quoted string could have quotes in the |
| 1417 | middle. Neither commas nor quotes count if they are escaped. |
| 1418 | Only double-quotes count, not single-quotes. |
| 1419 | """ |
| 1420 | res = [] |
| 1421 | part = '' |
| 1422 | |
| 1423 | escape = quote = False |
| 1424 | for cur in s: |
| 1425 | if escape: |
| 1426 | part += cur |
| 1427 | escape = False |
| 1428 | continue |
| 1429 | if quote: |
| 1430 | if cur == '\\': |
| 1431 | escape = True |
| 1432 | continue |
| 1433 | elif cur == '"': |
| 1434 | quote = False |
| 1435 | part += cur |
| 1436 | continue |
| 1437 | |
| 1438 | if cur == ',': |
| 1439 | res.append(part) |
| 1440 | part = '' |
| 1441 | continue |
| 1442 | |
| 1443 | if cur == '"': |
| 1444 | quote = True |
| 1445 | |
| 1446 | part += cur |
| 1447 | |
| 1448 | # append last part |
| 1449 | if part: |
| 1450 | res.append(part) |
| 1451 | |
| 1452 | return [part.strip() for part in res] |
| 1453 | |
| 1454 | class FileHandler(BaseHandler): |
| 1455 | # names for the localhost |
no test coverage detected
searching dependent graphs…