bare-quoted-string = DQUOTE *([FWS] qcontent) [FWS] DQUOTE A quoted-string without the leading or trailing white space. Its value is the text between the quote marks, with whitespace preserved and quoted pairs decoded.
(value)
| 1237 | return atext, value |
| 1238 | |
| 1239 | def get_bare_quoted_string(value): |
| 1240 | """bare-quoted-string = DQUOTE *([FWS] qcontent) [FWS] DQUOTE |
| 1241 | |
| 1242 | A quoted-string without the leading or trailing white space. Its |
| 1243 | value is the text between the quote marks, with whitespace |
| 1244 | preserved and quoted pairs decoded. |
| 1245 | """ |
| 1246 | if not value or value[0] != '"': |
| 1247 | raise errors.HeaderParseError( |
| 1248 | "expected '\"' but found '{}'".format(value)) |
| 1249 | bare_quoted_string = BareQuotedString() |
| 1250 | value = value[1:] |
| 1251 | if value and value[0] == '"': |
| 1252 | token, value = get_qcontent(value) |
| 1253 | bare_quoted_string.append(token) |
| 1254 | while value and value[0] != '"': |
| 1255 | if value[0] in WSP: |
| 1256 | token, value = get_fws(value) |
| 1257 | elif value[:2] == '=?': |
| 1258 | valid_ew = False |
| 1259 | try: |
| 1260 | token, value = get_encoded_word(value) |
| 1261 | bare_quoted_string.defects.append(errors.InvalidHeaderDefect( |
| 1262 | "encoded word inside quoted string")) |
| 1263 | valid_ew = True |
| 1264 | except errors.HeaderParseError: |
| 1265 | token, value = get_qcontent(value) |
| 1266 | # Collapse the whitespace between two encoded words that occur in a |
| 1267 | # bare-quoted-string. |
| 1268 | if valid_ew and len(bare_quoted_string) > 1: |
| 1269 | if (bare_quoted_string[-1].token_type == 'fws' and |
| 1270 | bare_quoted_string[-2].token_type == 'encoded-word'): |
| 1271 | bare_quoted_string[-1] = EWWhiteSpaceTerminal( |
| 1272 | bare_quoted_string[-1], 'fws') |
| 1273 | else: |
| 1274 | token, value = get_qcontent(value) |
| 1275 | bare_quoted_string.append(token) |
| 1276 | if not value: |
| 1277 | bare_quoted_string.defects.append(errors.InvalidHeaderDefect( |
| 1278 | "end of header inside quoted string")) |
| 1279 | return bare_quoted_string, value |
| 1280 | return bare_quoted_string, value[1:] |
| 1281 | |
| 1282 | def get_comment(value): |
| 1283 | """comment = "(" *([FWS] ccontent) [FWS] ")" |
no test coverage detected
searching dependent graphs…