| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011, 2012 Apple Inc. All rights reserved. | 2 * Copyright (C) 2011, 2012 Apple Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| 11 * documentation and/or other materials provided with the distribution. | 11 * documentation and/or other materials provided with the distribution. |
| 12 * | 12 * |
| 13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY | 13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY |
| 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
| 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR | 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR |
| 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
| 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
| 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
| 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
| 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 24 */ | 24 */ |
| 25 | 25 |
| 26 #include "core/html/MediaFragmentURIParser.h" | 26 #include "core/html/media/MediaFragmentURIParser.h" |
| 27 | 27 |
| 28 #include "wtf/text/CString.h" | 28 #include "wtf/text/CString.h" |
| 29 #include "wtf/text/StringBuilder.h" | 29 #include "wtf/text/StringBuilder.h" |
| 30 #include "wtf/text/WTFString.h" | 30 #include "wtf/text/WTFString.h" |
| 31 | 31 |
| 32 namespace blink { | 32 namespace blink { |
| 33 | 33 |
| 34 const unsigned nptIdentiferLength = 4; // "npt:" | 34 const unsigned nptIdentiferLength = 4; // "npt:" |
| 35 | 35 |
| 36 static String collectDigits(const LChar* input, | 36 static String collectDigits(const LChar* input, |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 continue; | 109 continue; |
| 110 } | 110 } |
| 111 | 111 |
| 112 // 2. For each name-value pair: | 112 // 2. For each name-value pair: |
| 113 // a. Decode percent-encoded octets in name and value as defined by RFC | 113 // a. Decode percent-encoded octets in name and value as defined by RFC |
| 114 // 3986. If either name or value are not valid percent-encoded strings, | 114 // 3986. If either name or value are not valid percent-encoded strings, |
| 115 // then remove the name-value pair from the list. | 115 // then remove the name-value pair from the list. |
| 116 String name = decodeURLEscapeSequences( | 116 String name = decodeURLEscapeSequences( |
| 117 fragmentString.substring(parameterStart, equalOffset - parameterStart)); | 117 fragmentString.substring(parameterStart, equalOffset - parameterStart)); |
| 118 String value; | 118 String value; |
| 119 if (equalOffset != parameterEnd) | 119 if (equalOffset != parameterEnd) { |
| 120 value = decodeURLEscapeSequences(fragmentString.substring( | 120 value = decodeURLEscapeSequences(fragmentString.substring( |
| 121 equalOffset + 1, parameterEnd - equalOffset - 1)); | 121 equalOffset + 1, parameterEnd - equalOffset - 1)); |
| 122 } |
| 122 | 123 |
| 123 // b. Convert name and value to Unicode strings by interpreting them as | 124 // b. Convert name and value to Unicode strings by interpreting them as |
| 124 // UTF-8. If either name or value are not valid UTF-8 strings, then | 125 // UTF-8. If either name or value are not valid UTF-8 strings, then |
| 125 // remove the name-value pair from the list. | 126 // remove the name-value pair from the list. |
| 126 bool validUTF8 = true; | 127 bool validUTF8 = true; |
| 127 if (!name.isEmpty()) { | 128 if (!name.isEmpty()) { |
| 128 name = name.utf8(StrictUTF8Conversion).data(); | 129 name = name.utf8(StrictUTF8Conversion).data(); |
| 129 validUTF8 = !name.isEmpty(); | 130 validUTF8 = !name.isEmpty(); |
| 130 } | 131 } |
| 131 if (validUTF8 && !value.isEmpty()) { | 132 if (validUTF8 && !value.isEmpty()) { |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 309 fraction = collectFraction(timeString, length, offset).toDouble(); | 310 fraction = collectFraction(timeString, length, offset).toDouble(); |
| 310 | 311 |
| 311 const int secondsPerHour = 3600; | 312 const int secondsPerHour = 3600; |
| 312 const int secondsPerMinute = 60; | 313 const int secondsPerMinute = 60; |
| 313 time = (value1 * secondsPerHour) + (value2 * secondsPerMinute) + value3 + | 314 time = (value1 * secondsPerHour) + (value2 * secondsPerMinute) + value3 + |
| 314 fraction; | 315 fraction; |
| 315 return true; | 316 return true; |
| 316 } | 317 } |
| 317 | 318 |
| 318 } // namespace blink | 319 } // namespace blink |
| OLD | NEW |