comment = "(" *([FWS] ccontent) [FWS] ")" ccontent = ctext / quoted-pair / comment We handle nested comments here, and quoted-pair in our qp-ctext routine.
(value)
| 1280 | return bare_quoted_string, value[1:] |
| 1281 | |
| 1282 | def get_comment(value): |
| 1283 | """comment = "(" *([FWS] ccontent) [FWS] ")" |
| 1284 | ccontent = ctext / quoted-pair / comment |
| 1285 | |
| 1286 | We handle nested comments here, and quoted-pair in our qp-ctext routine. |
| 1287 | """ |
| 1288 | if value and value[0] != '(': |
| 1289 | raise errors.HeaderParseError( |
| 1290 | "expected '(' but found '{}'".format(value)) |
| 1291 | comment = Comment() |
| 1292 | value = value[1:] |
| 1293 | while value and value[0] != ")": |
| 1294 | if value[0] in WSP: |
| 1295 | token, value = get_fws(value) |
| 1296 | elif value[0] == '(': |
| 1297 | token, value = get_comment(value) |
| 1298 | else: |
| 1299 | token, value = get_qp_ctext(value) |
| 1300 | comment.append(token) |
| 1301 | if not value: |
| 1302 | comment.defects.append(errors.InvalidHeaderDefect( |
| 1303 | "end of header inside comment")) |
| 1304 | return comment, value |
| 1305 | return comment, value[1:] |
| 1306 | |
| 1307 | def get_cfws(value): |
| 1308 | """CFWS = (1*([FWS] comment) [FWS]) / FWS |