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)
| 850 | |
| 851 | |
| 852 | def parse257(resp): |
| 853 | '''Parse the '257' response for a MKD or PWD request. |
| 854 | This is a response to a MKD or PWD request: a directory name. |
| 855 | Returns the directoryname in the 257 reply.''' |
| 856 | if resp[:3] != '257': |
| 857 | raise error_reply(resp) |
| 858 | if resp[3:5] != ' "': |
| 859 | return '' # Not compliant to RFC 959, but UNIX ftpd does this |
| 860 | dirname = '' |
| 861 | i = 5 |
| 862 | n = len(resp) |
| 863 | while i < n: |
| 864 | c = resp[i] |
| 865 | i = i+1 |
| 866 | if c == '"': |
| 867 | if i >= n or resp[i] != '"': |
| 868 | break |
| 869 | i = i+1 |
| 870 | dirname = dirname + c |
| 871 | return dirname |
| 872 | |
| 873 | |
| 874 | def print_line(line): |
no test coverage detected
searching dependent graphs…