| 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 637 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 648 url::Replacements<char> replacements; | 648 url::Replacements<char> replacements; |
| 649 replacements.SetPath(charactersOrEmpty(pathUTF8), url::Component(0, pathUTF8
.length())); | 649 replacements.SetPath(charactersOrEmpty(pathUTF8), url::Component(0, pathUTF8
.length())); |
| 650 replaceComponents(replacements); | 650 replaceComponents(replacements); |
| 651 } | 651 } |
| 652 | 652 |
| 653 String decodeURLEscapeSequences(const String& string) | 653 String decodeURLEscapeSequences(const String& string) |
| 654 { | 654 { |
| 655 return decodeURLEscapeSequences(string, UTF8Encoding()); | 655 return decodeURLEscapeSequences(string, UTF8Encoding()); |
| 656 } | 656 } |
| 657 | 657 |
| 658 // In KURL.cpp's implementation, this is called by every component getter. | |
| 659 // It will unescape every character, including '\0'. This is scary, and may | |
| 660 // cause security holes. We never call this function for components, and | |
| 661 // just return the ASCII versions instead. | |
| 662 // | |
| 663 // This function is also used to decode javascript: URLs and as a general | |
| 664 // purpose unescaping function. | |
| 665 // | |
| 666 // FIXME These should be merged to the KURL.cpp implementation. | |
| 667 String decodeURLEscapeSequences(const String& string, const WTF::TextEncoding& e
ncoding) | 658 String decodeURLEscapeSequences(const String& string, const WTF::TextEncoding& e
ncoding) |
| 668 { | 659 { |
| 669 // FIXME We can probably use KURL.cpp's version of this function | |
| 670 // without modification. However, I'm concerned about | |
| 671 // https://bugs.webkit.org/show_bug.cgi?id=20559 so am keeping this old | |
| 672 // custom code for now. Using their version will also fix the bug that | |
| 673 // we ignore the encoding. | |
| 674 // | |
| 675 // FIXME b/1350291: This does not get called very often. We just convert | |
| 676 // first to 8-bit UTF-8, then unescape, then back to 16-bit. This kind of | |
| 677 // sucks, and we don't use the encoding properly, which will make some | |
| 678 // obscure anchor navigations fail. | |
| 679 StringUTF8Adaptor stringUTF8(string); | 660 StringUTF8Adaptor stringUTF8(string); |
| 680 url::RawCanonOutputT<base::char16> unescaped; | 661 url::RawCanonOutputT<base::char16> unescaped; |
| 681 url::DecodeURLEscapeSequences(stringUTF8.data(), stringUTF8.length(), &unesc
aped); | 662 url::DecodeURLEscapeSequences(stringUTF8.data(), stringUTF8.length(), &unesc
aped); |
| 682 return StringImpl::create8BitIfPossible(reinterpret_cast<UChar*>(unescaped.d
ata()), unescaped.length()); | 663 return StringImpl::create8BitIfPossible(reinterpret_cast<UChar*>(unescaped.d
ata()), unescaped.length()); |
| 683 } | 664 } |
| 684 | 665 |
| 685 String encodeWithURLEscapeSequences(const String& notEncodedString) | 666 String encodeWithURLEscapeSequences(const String& notEncodedString) |
| 686 { | 667 { |
| 687 CString utf8 = UTF8Encoding().encode(notEncodedString, WTF::URLEncodedEntiti
esForUnencodables); | 668 CString utf8 = UTF8Encoding().encode(notEncodedString, WTF::URLEncodedEntiti
esForUnencodables); |
| 688 | 669 |
| (...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 915 m_string = AtomicString::fromUTF8(output.data(), output.length()); | 896 m_string = AtomicString::fromUTF8(output.data(), output.length()); |
| 916 } | 897 } |
| 917 | 898 |
| 918 bool KURL::isSafeToSendToAnotherThread() const | 899 bool KURL::isSafeToSendToAnotherThread() const |
| 919 { | 900 { |
| 920 return m_string.isSafeToSendToAnotherThread() | 901 return m_string.isSafeToSendToAnotherThread() |
| 921 && (!m_innerURL || m_innerURL->isSafeToSendToAnotherThread()); | 902 && (!m_innerURL || m_innerURL->isSafeToSendToAnotherThread()); |
| 922 } | 903 } |
| 923 | 904 |
| 924 } // namespace blink | 905 } // namespace blink |
| OLD | NEW |