OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2004, 2007, 2008, 2011, 2012 Apple Inc. All rights reserved. | 2 * Copyright (C) 2004, 2007, 2008, 2011, 2012 Apple Inc. All rights reserved. |
3 * Copyright (C) 2012 Research In Motion Limited. All rights reserved. | 3 * Copyright (C) 2012 Research In Motion Limited. All rights reserved. |
4 * Copyright (C) 2008, 2009, 2011 Google Inc. All rights reserved. | 4 * Copyright (C) 2008, 2009, 2011 Google Inc. All rights reserved. |
5 * | 5 * |
6 * Redistribution and use in source and binary forms, with or without | 6 * Redistribution and use in source and binary forms, with or without |
7 * modification, are permitted provided that the following conditions | 7 * modification, are permitted provided that the following conditions |
8 * are met: | 8 * are met: |
9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 class KURLCharsetConverter : public url_canon::CharsetConverter { | 93 class KURLCharsetConverter : public url_canon::CharsetConverter { |
94 public: | 94 public: |
95 // The encoding parameter may be 0, but in this case the object must not be
called. | 95 // The encoding parameter may be 0, but in this case the object must not be
called. |
96 explicit KURLCharsetConverter(const WTF::TextEncoding* encoding) | 96 explicit KURLCharsetConverter(const WTF::TextEncoding* encoding) |
97 : m_encoding(encoding) | 97 : m_encoding(encoding) |
98 { | 98 { |
99 } | 99 } |
100 | 100 |
101 virtual void ConvertFromUTF16(const url_parse::UTF16Char* input, int inputLe
ngth, url_canon::CanonOutput* output) | 101 virtual void ConvertFromUTF16(const url_parse::UTF16Char* input, int inputLe
ngth, url_canon::CanonOutput* output) |
102 { | 102 { |
103 CString encoded = m_encoding->encode(String(input, inputLength), WTF::UR
LEncodedEntitiesForUnencodables); | 103 CString encoded = m_encoding->normalizeAndEncode(String(input, inputLeng
th), WTF::URLEncodedEntitiesForUnencodables); |
104 output->Append(encoded.data(), static_cast<int>(encoded.length())); | 104 output->Append(encoded.data(), static_cast<int>(encoded.length())); |
105 } | 105 } |
106 | 106 |
107 private: | 107 private: |
108 const WTF::TextEncoding* m_encoding; | 108 const WTF::TextEncoding* m_encoding; |
109 }; | 109 }; |
110 | 110 |
111 } // namespace | 111 } // namespace |
112 | 112 |
113 bool isValidProtocol(const String& protocol) | 113 bool isValidProtocol(const String& protocol) |
(...skipping 481 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
595 // sucks, and we don't use the encoding properly, which will make some | 595 // sucks, and we don't use the encoding properly, which will make some |
596 // obscure anchor navigations fail. | 596 // obscure anchor navigations fail. |
597 StringUTF8Adaptor stringUTF8(string); | 597 StringUTF8Adaptor stringUTF8(string); |
598 url_canon::RawCanonOutputT<url_parse::UTF16Char> unescaped; | 598 url_canon::RawCanonOutputT<url_parse::UTF16Char> unescaped; |
599 url_util::DecodeURLEscapeSequences(stringUTF8.data(), stringUTF8.length(), &
unescaped); | 599 url_util::DecodeURLEscapeSequences(stringUTF8.data(), stringUTF8.length(), &
unescaped); |
600 return StringImpl::create8BitIfPossible(reinterpret_cast<UChar*>(unescaped.d
ata()), unescaped.length()); | 600 return StringImpl::create8BitIfPossible(reinterpret_cast<UChar*>(unescaped.d
ata()), unescaped.length()); |
601 } | 601 } |
602 | 602 |
603 String encodeWithURLEscapeSequences(const String& notEncodedString) | 603 String encodeWithURLEscapeSequences(const String& notEncodedString) |
604 { | 604 { |
605 CString utf8 = UTF8Encoding().encode(notEncodedString, WTF::URLEncodedEntiti
esForUnencodables); | 605 CString utf8 = UTF8Encoding().normalizeAndEncode(notEncodedString, WTF::URLE
ncodedEntitiesForUnencodables); |
606 | 606 |
607 url_canon::RawCanonOutputT<char> buffer; | 607 url_canon::RawCanonOutputT<char> buffer; |
608 int inputLength = utf8.length(); | 608 int inputLength = utf8.length(); |
609 if (buffer.length() < inputLength * 3) | 609 if (buffer.length() < inputLength * 3) |
610 buffer.Resize(inputLength * 3); | 610 buffer.Resize(inputLength * 3); |
611 | 611 |
612 url_util::EncodeURIComponent(utf8.data(), inputLength, &buffer); | 612 url_util::EncodeURIComponent(utf8.data(), inputLength, &buffer); |
613 String escaped(buffer.data(), buffer.length()); | 613 String escaped(buffer.data(), buffer.length()); |
614 // Unescape '/'; it's safe and much prettier. | 614 // Unescape '/'; it's safe and much prettier. |
615 escaped.replace("%2F", "/"); | 615 escaped.replace("%2F", "/"); |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
837 m_string = AtomicString::fromUTF8(output.data(), output.length()); | 837 m_string = AtomicString::fromUTF8(output.data(), output.length()); |
838 } | 838 } |
839 | 839 |
840 bool KURL::isSafeToSendToAnotherThread() const | 840 bool KURL::isSafeToSendToAnotherThread() const |
841 { | 841 { |
842 return m_string.isSafeToSendToAnotherThread() | 842 return m_string.isSafeToSendToAnotherThread() |
843 && (!m_innerURL || m_innerURL->isSafeToSendToAnotherThread()); | 843 && (!m_innerURL || m_innerURL->isSafeToSendToAnotherThread()); |
844 } | 844 } |
845 | 845 |
846 } // namespace WebCore | 846 } // namespace WebCore |
OLD | NEW |