[SCM] WebKit Debian packaging branch, debian/unstable, updated. debian/1.1.15-1-40151-g37bb677
darin
darin at 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Sat Sep 26 08:36:47 UTC 2009
The following commit has been merged in the debian/unstable branch:
commit 03ad654cf35b81a6f7688f76861c00ebf3c2057f
Author: darin <darin at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Sun Apr 25 15:10:57 2004 +0000
Reviewed by Dave.
- fixed <rdar://problem/3488892>: "anchor names with non-ASCII characters in them do not work"
* khtml/khtml_part.h: Add new gotoAnchor helper function, private.
* khtml/khtml_part.cpp:
(KHTMLPart::openURL): Call new gotoAnchor helper, since the code is now complex enough
that I don't want to copy and paste.
(KHTMLPart::gotoAnchor): Use the pages own encoding when decoding the string for an
anchor reference when going to an anchor. This matches the behavior of other browsers.
(KHTMLPart::slotFinishedParsing): Call new gotoAnchor helper.
* kwq/KWQKHTMLPart.mm: (KWQKHTMLPart::scrollToAnchor): Call new gotoAnchor helper.
* kwq/KWQKURL.h: Removed htmlRef function, and made encodedHtmlRef an inline.
Removed unused encoding hint parameter from setQuery (it's not a "hint" at all, but we
don't use it). Added a codec parameter to decode_string.
* kwq/KWQKURL.mm:
(hexDigitValue): Added. Helper function.
(KURL::setQuery): Removed unused parameter.
(KURL::decode_string): Implemented this function. It needs to use an encoding specified
by the web page. Also, we wanted to make a version that did not use the
CFURLCreateStringByReplacingPercentEscapes function anyway.
* kwq/KWQString.h: Added parameters to copyLatin1. Now you can copy an arbitrary substring.
* kwq/KWQString.mm: (QString::copyLatin1): Updated implementation to handle the two
new parameters.
* WebCore-tests.exp: Updated for change in signature of setQuery and decode_string.
* WebCore-combined.exp: Regenerated.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@6479 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebCore/ChangeLog-2005-08-23 b/WebCore/ChangeLog-2005-08-23
index 62f198a..ed8441a 100644
--- a/WebCore/ChangeLog-2005-08-23
+++ b/WebCore/ChangeLog-2005-08-23
@@ -1,5 +1,37 @@
2004-04-24 Darin Adler <darin at apple.com>
+ Reviewed by Dave.
+
+ - fixed <rdar://problem/3488892>: "anchor names with non-ASCII characters in them do not work"
+
+ * khtml/khtml_part.h: Add new gotoAnchor helper function, private.
+ * khtml/khtml_part.cpp:
+ (KHTMLPart::openURL): Call new gotoAnchor helper, since the code is now complex enough
+ that I don't want to copy and paste.
+ (KHTMLPart::gotoAnchor): Use the pages own encoding when decoding the string for an
+ anchor reference when going to an anchor. This matches the behavior of other browsers.
+ (KHTMLPart::slotFinishedParsing): Call new gotoAnchor helper.
+ * kwq/KWQKHTMLPart.mm: (KWQKHTMLPart::scrollToAnchor): Call new gotoAnchor helper.
+
+ * kwq/KWQKURL.h: Removed htmlRef function, and made encodedHtmlRef an inline.
+ Removed unused encoding hint parameter from setQuery (it's not a "hint" at all, but we
+ don't use it). Added a codec parameter to decode_string.
+ * kwq/KWQKURL.mm:
+ (hexDigitValue): Added. Helper function.
+ (KURL::setQuery): Removed unused parameter.
+ (KURL::decode_string): Implemented this function. It needs to use an encoding specified
+ by the web page. Also, we wanted to make a version that did not use the
+ CFURLCreateStringByReplacingPercentEscapes function anyway.
+
+ * kwq/KWQString.h: Added parameters to copyLatin1. Now you can copy an arbitrary substring.
+ * kwq/KWQString.mm: (QString::copyLatin1): Updated implementation to handle the two
+ new parameters.
+
+ * WebCore-tests.exp: Updated for change in signature of setQuery and decode_string.
+ * WebCore-combined.exp: Regenerated.
+
+2004-04-24 Darin Adler <darin at apple.com>
+
- fixed <rdar://problem/3570953>: "Update "Acknowledgements" to remove expat and possibly include libxml"
* WebCore.pbproj/project.pbxproj: Removed the part of the copyright notice that was for expat contributors.
diff --git a/WebCore/WebCore-combined.exp b/WebCore/WebCore-combined.exp
index 918eaf2..c7193ad 100644
--- a/WebCore/WebCore-combined.exp
+++ b/WebCore/WebCore-combined.exp
@@ -209,12 +209,12 @@ __ZN24KWQValueListIteratorImplneERKS_
__ZN24KWQValueListIteratorImplppEi
__ZN24KWQValueListIteratorImplppEv
__ZN4KURL11setProtocolERK7QString
-__ZN4KURL13decode_stringERK7QString
+__ZN4KURL13decode_stringERK7QStringPK10QTextCodec
__ZN4KURL6setRefERK7QString
__ZN4KURL7setHostERK7QString
__ZN4KURL7setPathERK7QString
__ZN4KURL7setPortEt
-__ZN4KURL8setQueryERK7QStringi
+__ZN4KURL8setQueryERK7QString
__ZN4KURLC1EPKc
__ZN4KURLC1ERK7QString
__ZN4KURLC1ERKS_
diff --git a/WebCore/WebCore-tests.exp b/WebCore/WebCore-tests.exp
index ed35454..df47833 100644
--- a/WebCore/WebCore-tests.exp
+++ b/WebCore/WebCore-tests.exp
@@ -100,12 +100,12 @@ __ZN24KWQValueListIteratorImplneERKS_
__ZN24KWQValueListIteratorImplppEi
__ZN24KWQValueListIteratorImplppEv
__ZN4KURL11setProtocolERK7QString
-__ZN4KURL13decode_stringERK7QString
+__ZN4KURL13decode_stringERK7QStringPK10QTextCodec
__ZN4KURL6setRefERK7QString
__ZN4KURL7setHostERK7QString
__ZN4KURL7setPathERK7QString
__ZN4KURL7setPortEt
-__ZN4KURL8setQueryERK7QStringi
+__ZN4KURL8setQueryERK7QString
__ZN4KURLC1EPKc
__ZN4KURLC1ERK7QString
__ZN4KURLC1ERKS_
diff --git a/WebCore/khtml/khtml_part.cpp b/WebCore/khtml/khtml_part.cpp
index c6bae04..dade478 100644
--- a/WebCore/khtml/khtml_part.cpp
+++ b/WebCore/khtml/khtml_part.cpp
@@ -449,8 +449,7 @@ bool KHTMLPart::openURL( const KURL &url )
m_url = url;
emit started( 0L );
- if ( !gotoAnchor( url.encodedHtmlRef()) )
- gotoAnchor( url.htmlRef() );
+ gotoAnchor();
d->m_bComplete = true;
d->m_doc->setParsing(false);
@@ -1640,6 +1639,23 @@ void KHTMLPart::stopAnimations()
}
}
+void KHTMLPart::gotoAnchor()
+{
+ QString ref = m_url.encodedHtmlRef();
+ if (!ref.isEmpty())
+ if (!gotoAnchor(ref)) {
+ // Can't use htmlRef() here because it doesn't know which encoding to use to decode.
+ // Decoding here has to match encoding in completeURL, which means it has to use the
+ // page's encoding rather than UTF-8.
+ if (d->m_decoder)
+#if !APPLE_CHANGES
+ gotoAnchor(KURL::decode_string(ref, d->m_decoder->codec()->mibEnum()));
+#else
+ gotoAnchor(KURL::decode_string(ref, d->m_decoder->codec()));
+#endif
+ }
+}
+
void KHTMLPart::slotFinishedParsing()
{
d->m_doc->setParsing(false);
@@ -1652,10 +1668,7 @@ void KHTMLPart::slotFinishedParsing()
// if not, remove them, relayout, and repaint
d->m_view->restoreScrollBar();
-
- if ( !m_url.encodedHtmlRef().isEmpty() )
- if ( !gotoAnchor( m_url.encodedHtmlRef()) )
- gotoAnchor( m_url.htmlRef() );
+ gotoAnchor();
checkCompleted();
}
diff --git a/WebCore/khtml/khtml_part.h b/WebCore/khtml/khtml_part.h
index 7b0c935..a7faf59 100644
--- a/WebCore/khtml/khtml_part.h
+++ b/WebCore/khtml/khtml_part.h
@@ -1202,6 +1202,11 @@ private:
bool handleMouseMoveEventOver(khtml::MouseMoveEvent *event);
void handleMouseMoveEventSelection(khtml::MouseMoveEvent *event);
+ /**
+ * @internal Extracts anchor and tries both encoded and decoded form.
+ */
+ void gotoAnchor();
+
#if APPLE_CHANGES
void handleMousePressEventSingleClick(khtml::MousePressEvent *event);
void handleMousePressEventDoubleClick(khtml::MousePressEvent *event);
diff --git a/WebCore/kwq/KWQKHTMLPart.mm b/WebCore/kwq/KWQKHTMLPart.mm
index b45be74..1dca482 100644
--- a/WebCore/kwq/KWQKHTMLPart.mm
+++ b/WebCore/kwq/KWQKHTMLPart.mm
@@ -1626,8 +1626,7 @@ void KWQKHTMLPart::scrollToAnchor(const KURL &URL)
m_url = URL;
started(0);
- if (!gotoAnchor(URL.encodedHtmlRef()))
- gotoAnchor(URL.htmlRef());
+ gotoAnchor();
// It's important to model this as a load that starts and immediately finishes.
// Otherwise, the parent frame may think we never finished loading.
diff --git a/WebCore/kwq/KWQKURL.h b/WebCore/kwq/KWQKURL.h
index 1409c3d..cc512cf 100644
--- a/WebCore/kwq/KWQKURL.h
+++ b/WebCore/kwq/KWQKURL.h
@@ -72,8 +72,7 @@ public:
QString ref() const;
bool hasRef() const;
- QString htmlRef() const;
- QString encodedHtmlRef() const;
+ QString encodedHtmlRef() const { return ref(); }
void setProtocol(const QString &);
void setHost(const QString &);
@@ -81,7 +80,7 @@ public:
void setUser(const QString &);
void setPass(const QString &);
void setPath(const QString &);
- void setQuery(const QString &, int encoding_hint=0);
+ void setQuery(const QString &);
void setRef(const QString &);
QString prettyURL() const;
@@ -89,7 +88,7 @@ public:
NSURL *getNSURL() const;
NSData *getNSData() const;
- static QString decode_string(const QString &);
+ static QString decode_string(const QString &, const QTextCodec * = 0);
static QString encode_string(const QString &);
friend bool operator==(const KURL &, const KURL &);
diff --git a/WebCore/kwq/KWQKURL.mm b/WebCore/kwq/KWQKURL.mm
index e727471..4172248 100644
--- a/WebCore/kwq/KWQKURL.mm
+++ b/WebCore/kwq/KWQKURL.mm
@@ -29,6 +29,9 @@
#import "KWQRegExp.h"
#import "KWQTextCodec.h"
+// FIXME: Should get this from a header.
+extern "C" int malloc_good_size(int size);
+
// You may have to turn this to 0 to compile without the headers for ICU installed.
#define HAVE_ICU_LIBRARY 1
@@ -211,6 +214,13 @@ static inline bool isPathSegmentEndChar(unsigned char c) { return characterClass
static inline bool isBadChar(unsigned char c) { return characterClassTable[c] & BadChar; }
static inline bool isHexDigit(unsigned char c) { return characterClassTable[c] & HexDigitChar; }
+static inline int hexDigitValue(unsigned char c)
+{
+ ASSERT(isHexDigit(c));
+ if (c < 'A')
+ return c - '0';
+ return (c - 'A' + 10) & 0xF; // handle both upper and lower case without a branch
+}
// KURL
@@ -771,7 +781,7 @@ void KURL::setRef(const QString &s)
}
}
-void KURL::setQuery(const QString &query, int encoding_hint)
+void KURL::setQuery(const QString &query)
{
if (m_isValid) {
QString q;
@@ -881,17 +891,68 @@ QString KURL::prettyURL() const
return result;
}
-QString KURL::decode_string(const QString &urlString)
+QString KURL::decode_string(const QString &urlString, const QTextCodec *codec)
{
- CFStringRef unescaped = CFURLCreateStringByReplacingPercentEscapes(NULL, urlString.getCFString(), CFSTR(""));
- if (!unescaped) {
- // FIXME: To avoid this error, we need to write our own unescaping function.
- ERROR("CFURL found ill-formed escape sequences in %s", urlString.ascii());
- return urlString;
+ QString result("");
+
+ char staticBuffer[2048];
+ char *buffer = staticBuffer;
+ int bufferLength = sizeof(staticBuffer);
+
+ int length = urlString.length();
+ int decodedPosition = 0;
+ int searchPosition = 0;
+ int encodedRunPosition;
+ while ((encodedRunPosition = urlString.find('%', searchPosition)) > 0) {
+ // Find the sequence of %-escape codes.
+ int encodedRunEnd = encodedRunPosition;
+ while (length - encodedRunEnd >= 3
+ && urlString[encodedRunEnd] == '%'
+ && isHexDigit(urlString[encodedRunEnd + 1].latin1())
+ && isHexDigit(urlString[encodedRunEnd + 2].latin1()))
+ encodedRunEnd += 3;
+ if (encodedRunEnd == encodedRunPosition) {
+ ++searchPosition;
+ continue;
+ }
+ searchPosition = encodedRunEnd;
+
+ // Copy the entire %-escape sequence into an 8-bit buffer.
+ int encodedRunLength = encodedRunEnd - encodedRunPosition;
+ if (encodedRunLength + 1 > bufferLength) {
+ if (buffer != staticBuffer)
+ free(buffer);
+ bufferLength = malloc_good_size(encodedRunLength + 1);
+ buffer = static_cast<char *>(malloc(bufferLength));
+ }
+ urlString.copyLatin1(buffer, encodedRunPosition, encodedRunLength);
+
+ // Decode the %-escapes into bytes.
+ char *p = buffer;
+ const char *q = buffer;
+ while (*q) {
+ *p++ = (hexDigitValue(q[1]) << 4) | hexDigitValue(q[2]);
+ q += 3;
+ }
+
+ // Decode the bytes into Unicode characters.
+ QString decoded = codec->toUnicode(buffer, p - buffer);
+ if (decoded.isEmpty()) {
+ continue;
+ }
+
+ // Build up the string with what we just skipped and what we just decoded.
+ result.append(urlString.mid(decodedPosition, encodedRunPosition - decodedPosition));
+ result.append(decoded);
+ decodedPosition = encodedRunEnd;
}
- QString qUnescaped = QString::fromCFString(unescaped);
- CFRelease(unescaped);
- return qUnescaped;
+
+ result.append(urlString.mid(decodedPosition, length - decodedPosition));
+
+ if (buffer != staticBuffer)
+ free(buffer);
+
+ return result;
}
static void appendEscapingBadChars(char*& buffer, const char *strStart, size_t length)
@@ -1345,16 +1406,6 @@ void KURL::parse(const char *url, const QString *originalString)
}
}
-QString KURL::encodedHtmlRef() const
-{
- return ref();
-}
-
-QString KURL::htmlRef() const
-{
- return decode_string(ref());
-}
-
bool operator==(const KURL &a, const KURL &b)
{
return a.urlString == b.urlString;
diff --git a/WebCore/kwq/KWQString.h b/WebCore/kwq/KWQString.h
index 37805b5..73bd275 100644
--- a/WebCore/kwq/KWQString.h
+++ b/WebCore/kwq/KWQString.h
@@ -418,7 +418,7 @@ public:
bool isAllASCII() const;
bool isAllLatin1() const;
bool hasFastLatin1() const;
- void copyLatin1(char *latin1) const;
+ void copyLatin1(char *buffer, uint position = 0, uint length = 0xffffffff) const;
QCString utf8() const { int length; return utf8(length); }
QCString utf8(int &length) const;
QCString local8Bit() const;
diff --git a/WebCore/kwq/KWQString.mm b/WebCore/kwq/KWQString.mm
index fbbcc3c..042cf25 100644
--- a/WebCore/kwq/KWQString.mm
+++ b/WebCore/kwq/KWQString.mm
@@ -38,9 +38,7 @@
// Why can't I find this in a header anywhere? It's too bad we have
// to wire knowledge of allocation sizes, but it makes a huge diffence.
-extern "C" {
-int malloc_good_size(int size);
-}
+extern "C" int malloc_good_size(int size);
#define ALLOC_QCHAR_GOOD_SIZE(X) (malloc_good_size(X*sizeof(QChar))/sizeof(QChar))
#define ALLOC_CHAR_GOOD_SIZE(X) (malloc_good_size(X))
@@ -1571,22 +1569,29 @@ bool QString::hasFastLatin1() const
return data->_isAsciiValid;
}
-void QString::copyLatin1(char *buffer) const
+void QString::copyLatin1(char *buffer, uint position, uint maxLength) const
{
KWQStringData *data = *dataHandle;
int length = data->_length;
+ if (position > static_cast<uint>(length))
+ length = 0;
+ else
+ length -= position;
+ if (static_cast<uint>(length) > maxLength)
+ length = static_cast<int>(maxLength);
+
+ buffer[length] = 0;
if (data->_isAsciiValid) {
- memcpy(buffer, data->_ascii, length + 1);
+ memcpy(buffer, data->_ascii + position, length);
return;
}
ASSERT(data->_isUnicodeValid);
- const QChar *uc = data->_unicode;
+ const QChar *uc = data->_unicode + position;
while (length--)
*buffer++ = *uc++;
- *buffer = 0;
}
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list