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)
| 1220 | return atext, value |
| 1221 | |
| 1222 | def get_bare_quoted_string(value): |
| 1223 | """bare-quoted-string = DQUOTE *([FWS] qcontent) [FWS] DQUOTE |
| 1224 | |
| 1225 | A quoted-string without the leading or trailing white space. Its |
| 1226 | value is the text between the quote marks, with whitespace |
| 1227 | preserved and quoted pairs decoded. |
| 1228 | """ |
| 1229 | if not value or value[0] != '"': |
| 1230 | raise errors.HeaderParseError( |
| 1231 | "expected '\"' but found '{}'".format(value)) |
| 1232 | bare_quoted_string = BareQuotedString() |
| 1233 | value = value[1:] |
| 1234 | if value and value[0] == '"': |
| 1235 | token, value = get_qcontent(value) |
| 1236 | bare_quoted_string.append(token) |
| 1237 | while value and value[0] != '"': |
| 1238 | if value[0] in WSP: |
| 1239 | token, value = get_fws(value) |
| 1240 | elif value[:2] == '=?': |
| 1241 | valid_ew = False |
| 1242 | try: |
| 1243 | token, value = get_encoded_word(value) |
| 1244 | bare_quoted_string.defects.append(errors.InvalidHeaderDefect( |
| 1245 | "encoded word inside quoted string")) |
| 1246 | valid_ew = True |
| 1247 | except errors.HeaderParseError: |
| 1248 | token, value = get_qcontent(value) |
| 1249 | # Collapse the whitespace between two encoded words that occur in a |
| 1250 | # bare-quoted-string. |
| 1251 | if valid_ew and len(bare_quoted_string) > 1: |
| 1252 | if (bare_quoted_string[-1].token_type == 'fws' and |
| 1253 | bare_quoted_string[-2].token_type == 'encoded-word'): |
| 1254 | bare_quoted_string[-1] = EWWhiteSpaceTerminal( |
| 1255 | bare_quoted_string[-1], 'fws') |
| 1256 | else: |
| 1257 | token, value = get_qcontent(value) |
| 1258 | bare_quoted_string.append(token) |
| 1259 | if not value: |
| 1260 | bare_quoted_string.defects.append(errors.InvalidHeaderDefect( |
| 1261 | "end of header inside quoted string")) |
| 1262 | return bare_quoted_string, value |
| 1263 | return bare_quoted_string, value[1:] |
| 1264 | |
| 1265 | def get_comment(value): |
| 1266 | """comment = "(" *([FWS] ccontent) [FWS] ")" |
no test coverage detected