| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2006 Alexey Proskuryakov (ap@webkit.org) | 2 * Copyright (C) 2006 Alexey Proskuryakov (ap@webkit.org) |
| 3 * Copyright (C) 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. | 3 * Copyright (C) 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. |
| 4 * Copyright (C) 2009 Torch Mobile Inc. http://www.torchmobile.com/ | 4 * Copyright (C) 2009 Torch Mobile Inc. http://www.torchmobile.com/ |
| 5 * Copyright (C) 2009 Google Inc. All rights reserved. | 5 * Copyright (C) 2009 Google Inc. All rights reserved. |
| 6 * Copyright (C) 2011 Apple Inc. All Rights Reserved. | 6 * Copyright (C) 2011 Apple Inc. All Rights Reserved. |
| 7 * | 7 * |
| 8 * Redistribution and use in source and binary forms, with or without | 8 * Redistribution and use in source and binary forms, with or without |
| 9 * modification, are permitted provided that the following conditions | 9 * modification, are permitted provided that the following conditions |
| 10 * are met: | 10 * are met: |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 // without a disposition token... screen those out. | 161 // without a disposition token... screen those out. |
| 162 if (!isValidHTTPToken(dispositionType)) | 162 if (!isValidHTTPToken(dispositionType)) |
| 163 return ContentDispositionNone; | 163 return ContentDispositionNone; |
| 164 | 164 |
| 165 // We have a content-disposition of "attachment" or unknown. | 165 // We have a content-disposition of "attachment" or unknown. |
| 166 // RFC 2183, section 2.8 says that an unknown disposition | 166 // RFC 2183, section 2.8 says that an unknown disposition |
| 167 // value should be treated as "attachment" | 167 // value should be treated as "attachment" |
| 168 return ContentDispositionAttachment; | 168 return ContentDispositionAttachment; |
| 169 } | 169 } |
| 170 | 170 |
| 171 bool parseHTTPRefresh(const String& refresh, bool fromHttpEquivMeta, double& del
ay, String& url) | |
| 172 { | |
| 173 unsigned len = refresh.length(); | |
| 174 unsigned pos = 0; | |
| 175 | |
| 176 if (!skipWhiteSpace(refresh, pos, fromHttpEquivMeta)) | |
| 177 return false; | |
| 178 | |
| 179 while (pos != len && refresh[pos] != ',' && refresh[pos] != ';') | |
| 180 ++pos; | |
| 181 | |
| 182 if (pos == len) { // no URL | |
| 183 url = String(); | |
| 184 bool ok; | |
| 185 delay = refresh.stripWhiteSpace().toDouble(&ok); | |
| 186 return ok; | |
| 187 } else { | |
| 188 bool ok; | |
| 189 delay = refresh.left(pos).stripWhiteSpace().toDouble(&ok); | |
| 190 if (!ok) | |
| 191 return false; | |
| 192 | |
| 193 ++pos; | |
| 194 skipWhiteSpace(refresh, pos, fromHttpEquivMeta); | |
| 195 unsigned urlStartPos = pos; | |
| 196 if (refresh.find("url", urlStartPos, false) == urlStartPos) { | |
| 197 urlStartPos += 3; | |
| 198 skipWhiteSpace(refresh, urlStartPos, fromHttpEquivMeta); | |
| 199 if (refresh[urlStartPos] == '=') { | |
| 200 ++urlStartPos; | |
| 201 skipWhiteSpace(refresh, urlStartPos, fromHttpEquivMeta); | |
| 202 } else { | |
| 203 urlStartPos = pos; // e.g. "Refresh: 0; url.html" | |
| 204 } | |
| 205 } | |
| 206 | |
| 207 unsigned urlEndPos = len; | |
| 208 | |
| 209 if (refresh[urlStartPos] == '"' || refresh[urlStartPos] == '\'') { | |
| 210 UChar quotationMark = refresh[urlStartPos]; | |
| 211 urlStartPos++; | |
| 212 while (urlEndPos > urlStartPos) { | |
| 213 urlEndPos--; | |
| 214 if (refresh[urlEndPos] == quotationMark) | |
| 215 break; | |
| 216 } | |
| 217 | |
| 218 // https://bugs.webkit.org/show_bug.cgi?id=27868 | |
| 219 // Sometimes there is no closing quote for the end of the URL even t
hough there was an opening quote. | |
| 220 // If we looped over the entire alleged URL string back to the openi
ng quote, just go ahead and use everything | |
| 221 // after the opening quote instead. | |
| 222 if (urlEndPos == urlStartPos) | |
| 223 urlEndPos = len; | |
| 224 } | |
| 225 | |
| 226 url = refresh.substring(urlStartPos, urlEndPos - urlStartPos).stripWhite
Space(); | |
| 227 return true; | |
| 228 } | |
| 229 } | |
| 230 | |
| 231 double parseDate(const String& value) | 171 double parseDate(const String& value) |
| 232 { | 172 { |
| 233 return parseDateFromNullTerminatedCharacters(value.utf8().data()); | 173 return parseDateFromNullTerminatedCharacters(value.utf8().data()); |
| 234 } | 174 } |
| 235 | 175 |
| 236 // FIXME: This function doesn't comply with RFC 6266. | 176 // FIXME: This function doesn't comply with RFC 6266. |
| 237 // For example, this function doesn't handle the interaction between " and ; | 177 // For example, this function doesn't handle the interaction between " and ; |
| 238 // that arises from quoted-string, nor does this function properly unquote | 178 // that arises from quoted-string, nor does this function properly unquote |
| 239 // attribute values. Further this function appears to process parameter names | 179 // attribute values. Further this function appears to process parameter names |
| 240 // in a case-sensitive manner. (There are likely other bugs as well.) | 180 // in a case-sensitive manner. (There are likely other bugs as well.) |
| (...skipping 574 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 815 if (!cacheControlHeader.containsNoCache) { | 755 if (!cacheControlHeader.containsNoCache) { |
| 816 // Handle Pragma: no-cache | 756 // Handle Pragma: no-cache |
| 817 // This is deprecated and equivalent to Cache-control: no-cache | 757 // This is deprecated and equivalent to Cache-control: no-cache |
| 818 // Don't bother tokenizing the value, it is not important | 758 // Don't bother tokenizing the value, it is not important |
| 819 cacheControlHeader.containsNoCache = pragmaValue.lower().contains(noCach
eDirective); | 759 cacheControlHeader.containsNoCache = pragmaValue.lower().contains(noCach
eDirective); |
| 820 } | 760 } |
| 821 return cacheControlHeader; | 761 return cacheControlHeader; |
| 822 } | 762 } |
| 823 | 763 |
| 824 } | 764 } |
| OLD | NEW |