Commit 0b46dc74 authored by rjw's avatar rjw
Browse files

Made decoder more robust wrt nulls in content. Changed use

        of QCString to null safe QString rather than modify
        content.

        * khtml/misc/decoder.cpp:
        (Decoder::decode):
        (Decoder::flush):
        * khtml/misc/decoder.h:
        * kwq/KWQString.mm:
        (QString::fromStringWithEncoding):

        Change link dragging behavior.  Drags URL, not URL contents.
        Still need to generate better image for dragging, will copy OmniWeb
        and drag link text.

        * WebView.subproj/WebHTMLView.m:
        (-[WebHTMLView mouseDragged:]):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@1941 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent a44cf409
2002-08-30 Richard Williamson (Home) <rjw@apple.com>
Made decoder more robust wrt nulls in content. Changed use
of QCString to null safe QString rather than modify
content.
* khtml/misc/decoder.cpp:
(Decoder::decode):
(Decoder::flush):
* khtml/misc/decoder.h:
* kwq/KWQString.mm:
(QString::fromStringWithEncoding):
2002-08-30 Darin Adler <darin@apple.com>
- fixed 3027407 -- Console error refers to closed bug
......
2002-08-30 Richard Williamson (Home) <rjw@apple.com>
Made decoder more robust wrt nulls in content. Changed use
of QCString to null safe QString rather than modify
content.
* khtml/misc/decoder.cpp:
(Decoder::decode):
(Decoder::flush):
* khtml/misc/decoder.h:
* kwq/KWQString.mm:
(QString::fromStringWithEncoding):
2002-08-30 Darin Adler <darin@apple.com>
- fixed 3027407 -- Console error refers to closed bug
......
2002-08-30 Richard Williamson (Home) <rjw@apple.com>
Made decoder more robust wrt nulls in content. Changed use
of QCString to null safe QString rather than modify
content.
* khtml/misc/decoder.cpp:
(Decoder::decode):
(Decoder::flush):
* khtml/misc/decoder.h:
* kwq/KWQString.mm:
(QString::fromStringWithEncoding):
2002-08-30 Darin Adler <darin@apple.com>
- fixed 3027407 -- Console error refers to closed bug
......
......@@ -356,14 +356,24 @@ QString Decoder::decode(const char *data, int len)
i--;
}
}
#ifdef APPLE_CHANGES
QString appendString(data, len);
buffer += appendString;
#else
buffer += QCString(data, len+1);
#endif
// we still don't have an encoding, and are in the head
// the following tags are allowed in <head>:
// SCRIPT|STYLE|META|LINK|OBJECT|TITLE|BASE
#ifdef APPLE_CHANGES
const char *ptr = buffer.latin1();
int pLen = buffer.length();
while(pLen--)
#else
const char *ptr = buffer.data();
while(*ptr != '\0')
#endif
{
if(*ptr == '<') {
bool end = false;
......@@ -461,7 +471,8 @@ QString Decoder::decode(const char *data, int len)
}
#ifdef APPLE_CHANGES
else {
buffer += QCString(data, len+1);
QString appendString(data, len);
buffer += appendString;
}
#endif /* APPLE_CHANGES */
......@@ -515,7 +526,7 @@ QString Decoder::decode(const char *data, int len)
#else
if(!buffer.isEmpty() && enc != "ISO-10646-UCS-2") {
#endif
out = m_decoder->toUnicode(buffer, buffer.length());
out = m_decoder->toUnicode(buffer.latin1(), buffer.length());
buffer = "";
} else {
if(m_codec->mibEnum() != 1000) // utf16
......@@ -550,7 +561,7 @@ QString Decoder::decode(const char *data, int len)
QString Decoder::flush() const
{
return m_decoder->toUnicode(buffer, buffer.length());
return m_decoder->toUnicode(buffer.latin1(), buffer.length());
}
// -----------------------------------------------------------------------------
......
......@@ -53,8 +53,11 @@ protected:
QTextDecoder *m_decoder; // only used for utf16
QCString enc;
#ifdef APPLE_CHANGES
QString buffer;
#else
QCString buffer;
#endif
bool body;
bool beginning;
bool visualRTL;
......
......@@ -728,26 +728,25 @@ void QString::setBufferFromCFString(CFStringRef cfs)
}
}
// This function is used by the decoder. It will be replace with TEC eventually.
QString QString::fromStringWithEncoding(const char *chs, int len, CFStringEncoding encoding)
{
QString qs;
if (chs && *chs) {
CFMutableStringRef s = CFStringCreateMutable(kCFAllocatorDefault, 0);
if (s) {
if (len < 0) {
// append null-terminated string
CFStringAppendCString(s, chs, encoding);
} else {
// append length-specified string
char *buf = (char *)CFAllocatorAllocate(kCFAllocatorDefault, len + 1, 0);
strncpy(buf, chs, len);
*(buf + len) = '\0';
CFStringAppendCString(s, buf, encoding);
qs.setBufferFromCFString(s);
CFAllocatorDeallocate(kCFAllocatorDefault, buf);
}
}
CFStringRef decoderString = CFStringCreateWithBytes (kCFAllocatorDefault, (const UInt8 *)chs, len, encoding, false);
CFStringAppend (s, decoderString);
qs.setBufferFromCFString(s);
fprintf (stderr, "strlen(chs) = %d, CFStringLength (decoderString) = %d, qs.length() = %d, len = %d\n",
(int)strlen(chs), (int)CFStringGetLength (decoderString), (int)qs.length(), (int)len);
CFRelease (s);
CFRelease (decoderString);
}
return qs;
}
......
2002-08-30 Richard Williamson (Home) <rjw@apple.com>
Change link dragging behavior. Drags URL, not URL contents.
Still need to generate better image for dragging, will copy OmniWeb
and drag link text.
* WebView.subproj/WebHTMLView.m:
(-[WebHTMLView mouseDragged:]):
2002-08-30 Darin Adler <darin@apple.com>
* WebKit.pbproj/project.pbxproj: Allowed the new Project Builder to put in
......
2002-08-30 Richard Williamson (Home) <rjw@apple.com>
Change link dragging behavior. Drags URL, not URL contents.
Still need to generate better image for dragging, will copy OmniWeb
and drag link text.
* WebView.subproj/WebHTMLView.m:
(-[WebHTMLView mouseDragged:]):
2002-08-30 Darin Adler <darin@apple.com>
* WebKit.pbproj/project.pbxproj: Allowed the new Project Builder to put in
......
......@@ -13,6 +13,7 @@
#import <WebKit/WebException.h>
#import <WebKit/WebFrame.h>
#import <WebKit/WebHTMLViewPrivate.h>
#import <WebKit/WebIconLoader.h>
#import <WebKit/WebKitDebug.h>
#import <WebKit/WebNSViewExtras.h>
#import <WebKit/WebTextRenderer.h>
......@@ -435,9 +436,24 @@ - (void)mouseDragged:(NSEvent *)event
_private->draggedURL = linkURL;
[_private->draggedURL retain];
#ifdef DRAG_FILES
NSArray *fileType = [NSArray arrayWithObject:[[_private->draggedURL path] pathExtension]];
NSRect rect = NSMakeRect(point.x + -16, point.y - 16, 32, 32);
[self dragPromisedFilesOfTypes: fileType fromRect: rect source: self slideBack: YES event: event];
#else
NSPasteboard *pasteboard = [NSPasteboard pasteboardWithName:NSDragPboard];
[pasteboard declareTypes:[NSArray arrayWithObject:NSURLPboardType] owner:nil];
[_private->draggedURL writeToPasteboard: pasteboard];
[self dragImage:[WebIconLoader defaultIcon]
at:[self convertPoint:[event locationInWindow] fromView:nil]
offset:NSMakeSize(0.0,0.0)
event:event
pasteboard:pasteboard
source:self
slideBack:NO];
#endif
return;
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment