Parse the '257' response for a MKD or PWD request. This is a response to a MKD or PWD request: a directory name. Returns the directoryname in the 257 reply.
(resp)
| 872 | |
| 873 | |
| 874 | def parse257(resp): |
| 875 | '''Parse the '257' response for a MKD or PWD request. |
| 876 | This is a response to a MKD or PWD request: a directory name. |
| 877 | Returns the directoryname in the 257 reply.''' |
| 878 | if resp[:3] != '257': |
| 879 | raise error_reply(resp) |
| 880 | if resp[3:5] != ' "': |
| 881 | return '' # Not compliant to RFC 959, but UNIX ftpd does this |
| 882 | dirname = '' |
| 883 | i = 5 |
| 884 | n = len(resp) |
| 885 | while i < n: |
| 886 | c = resp[i] |
| 887 | i = i+1 |
| 888 | if c == '"': |
| 889 | if i >= n or resp[i] != '"': |
| 890 | break |
| 891 | i = i+1 |
| 892 | dirname = dirname + c |
| 893 | return dirname |
| 894 | |
| 895 | |
| 896 | def print_line(line): |
no test coverage detected