[webkit-changes] cvs commit: WebKit/WebCoreSupport.subproj WebImageData.m

Adele adele at opensource.apple.com
Thu Jul 21 17:02:24 PDT 2005


adele       05/07/21 17:02:24

  Modified:    .        ChangeLog
               Plugins.subproj WebBasePluginPackage.h
                        WebBasePluginPackage.m WebNetscapePluginPackage.m
                        WebPluginPackage.m
               WebCoreSupport.subproj WebImageData.m
  Log:
          Reviewed by Chris Blumenberg.
  
          - fixed <rdar://problem/4132797> don't register thin PPC WebKit plug-ins
          Merged fix for:
          <rdar://problem/4127100> [WebKit] 8B1016: After installing Acrobat Reader, can no longer see pdf's in Safari
  
          * Plugins.subproj/WebBasePluginPackage.h: Added isNativeLibraryData method.
          * Plugins.subproj/WebBasePluginPackage.m: (-[WebBasePluginPackage isNativeLibraryData:]): Added isNativeLibraryData method.
          * Plugins.subproj/WebNetscapePluginPackage.m: (-[WebNetscapePluginPackage initWithPath:]):
            calls isNativeLibraryData to determine whether or not to register the plug-in.
          * Plugins.subproj/WebPluginPackage.m: (-[WebPluginPackage initWithPath:]): ditto.
          * WebCoreSupport.subproj/WebImageData.m: (-[WebImageData _checkSolidColor:]): added comment for #ifdef.
  
  Revision  Changes    Path
  1.3248    +15 -0     WebKit/ChangeLog
  
  Index: ChangeLog
  ===================================================================
  RCS file: /cvs/root/WebKit/ChangeLog,v
  retrieving revision 1.3247
  retrieving revision 1.3248
  diff -u -r1.3247 -r1.3248
  --- ChangeLog	21 Jul 2005 20:33:53 -0000	1.3247
  +++ ChangeLog	22 Jul 2005 00:02:19 -0000	1.3248
  @@ -1,3 +1,18 @@
  +2005-07-21  Adele Peterson  <adele at apple.com>
  +
  +        Reviewed by Chris Blumenberg.
  +
  +        - fixed <rdar://problem/4132797> don't register thin PPC WebKit plug-ins
  +        Merged fix for:
  +        <rdar://problem/4127100> [WebKit] 8B1016: After installing Acrobat Reader, can no longer see pdf's in Safari
  +
  +        * Plugins.subproj/WebBasePluginPackage.h: Added isNativeLibraryData method.
  +        * Plugins.subproj/WebBasePluginPackage.m: (-[WebBasePluginPackage isNativeLibraryData:]): Added isNativeLibraryData method.
  +        * Plugins.subproj/WebNetscapePluginPackage.m: (-[WebNetscapePluginPackage initWithPath:]):
  +          calls isNativeLibraryData to determine whether or not to register the plug-in.
  +        * Plugins.subproj/WebPluginPackage.m: (-[WebPluginPackage initWithPath:]): ditto.
  +        * WebCoreSupport.subproj/WebImageData.m: (-[WebImageData _checkSolidColor:]): added comment for #ifdef.
  +
   2005-07-21  Geoffrey Garen  <ggaren at apple.com>
   
           Reviewed by NOBODY (OOPS!).
  
  
  
  1.17      +2 -0      WebKit/Plugins.subproj/WebBasePluginPackage.h
  
  Index: WebBasePluginPackage.h
  ===================================================================
  RCS file: /cvs/root/WebKit/Plugins.subproj/WebBasePluginPackage.h,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- WebBasePluginPackage.h	5 Jun 2005 17:54:34 -0000	1.16
  +++ WebBasePluginPackage.h	22 Jul 2005 00:02:23 -0000	1.17
  @@ -89,4 +89,6 @@
   - (BOOL)isQuickTimePlugIn;
   - (BOOL)isJavaPlugIn;
   
  +- (BOOL)isNativeLibraryData:(NSData *)data;
  +
   @end
  
  
  
  1.25      +23 -0     WebKit/Plugins.subproj/WebBasePluginPackage.m
  
  Index: WebBasePluginPackage.m
  ===================================================================
  RCS file: /cvs/root/WebKit/Plugins.subproj/WebBasePluginPackage.m,v
  retrieving revision 1.24
  retrieving revision 1.25
  diff -u -r1.24 -r1.25
  --- WebBasePluginPackage.m	6 Jun 2005 03:44:54 -0000	1.24
  +++ WebBasePluginPackage.m	22 Jul 2005 00:02:23 -0000	1.25
  @@ -35,6 +35,9 @@
   
   #import <WebKitSystemInterface.h>
   
  +#import <mach-o/arch.h>
  +#import <mach-o/loader.h>
  +
   #define JavaCocoaPluginIdentifier 	@"com.apple.JavaPluginCocoa"
   #define JavaCarbonPluginIdentifier 	@"com.apple.JavaAppletPlugin"
   #define JavaCFMPluginFilename		@"Java Applet Plugin Enabler"
  @@ -399,6 +402,26 @@
           [[path lastPathComponent] _webkit_isCaseInsensitiveEqualToString:JavaCFMPluginFilename];
   }
   
  +- (BOOL)isNativeLibraryData:(NSData *)data
  +{  
  +    // If we have a 32-bit thin Mach-O file, see if we have an i386 binary.  If not, don't load it.
  +    // This is designed to be the safest possible test for now.  We'll only reject files that we
  +    // can easily tell are wrong.
  +    if ([data length] >= sizeof(struct mach_header)) {
  +        const NXArchInfo *localArch = NXGetLocalArchInfo();
  +        if (localArch != NULL) {
  +            struct mach_header *header = (struct mach_header *)[data bytes];
  +            if (header->magic == MH_MAGIC) {
  +                return (header->cputype == localArch->cputype);
  +            }
  +            if (header->magic == MH_CIGAM) {
  +                return ((cpu_type_t) OSSwapInt32(header->cputype) == localArch->cputype);
  +            }
  +        }
  +    }
  +    return YES;
  +}
  +
   @end
   
   @implementation NSArray (WebPluginExtensions)
  
  
  
  1.43      +10 -3     WebKit/Plugins.subproj/WebNetscapePluginPackage.m
  
  Index: WebNetscapePluginPackage.m
  ===================================================================
  RCS file: /cvs/root/WebKit/Plugins.subproj/WebNetscapePluginPackage.m,v
  retrieving revision 1.42
  retrieving revision 1.43
  diff -u -r1.42 -r1.43
  --- WebNetscapePluginPackage.m	5 Jun 2005 17:54:35 -0000	1.42
  +++ WebNetscapePluginPackage.m	22 Jul 2005 00:02:23 -0000	1.43
  @@ -204,14 +204,17 @@
           isBundle = YES;
           CFBundleGetPackageInfo(cfBundle, &type, NULL);
       }
  -#ifdef __ppc__
       // Single-file plug-in with resource fork
       else {
  +#ifdef __ppc__
           type = [[[NSFileManager defaultManager] fileAttributesAtPath:path traverseLink:YES] fileHFSTypeCode];
           isBundle = NO;
           isCFM = YES;
  -    }
  +#else
  +        [self release];
  +        return nil;
   #endif
  +    }
       
       if (type != FOUR_CHAR_CODE('BRPL')) {
           [self release];
  @@ -221,7 +224,7 @@
       // Check if the executable is Mach-O or CFM.
       if (bundle) {
           NSFileHandle *executableFile = [NSFileHandle fileHandleForReadingAtPath:[bundle executablePath]];
  -        NSData *data = [executableFile readDataOfLength:8];
  +        NSData *data = [executableFile readDataOfLength:512];
           [executableFile closeFile];
           // Check the length of the data before calling memcmp. We think this fixes 3782543.
           if (data == nil || [data length] < 8) {
  @@ -236,6 +239,10 @@
               return nil;
           }
   #endif
  +        if (![self isNativeLibraryData:data]) {
  +            [self release];
  +            return nil;
  +        }
       }
   
       if (![self getPluginInfoFromPLists] && ![self getPluginInfoFromResources]) {
  
  
  
  1.20      +8 -0      WebKit/Plugins.subproj/WebPluginPackage.m
  
  Index: WebPluginPackage.m
  ===================================================================
  RCS file: /cvs/root/WebKit/Plugins.subproj/WebPluginPackage.m,v
  retrieving revision 1.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- WebPluginPackage.m	5 Jun 2005 17:54:35 -0000	1.19
  +++ WebPluginPackage.m	22 Jul 2005 00:02:23 -0000	1.20
  @@ -61,6 +61,14 @@
               return nil;
           }
       }
  +    
  +    NSFileHandle *executableFile = [NSFileHandle fileHandleForReadingAtPath:[bundle executablePath]];
  +    NSData *data = [executableFile readDataOfLength:512];
  +    [executableFile closeFile];
  +    if (![self isNativeLibraryData:data]) {
  +        [self release];
  +        return nil;
  +    }
   
       if (![self getPluginInfoFromPLists]) {
           [self release];
  
  
  
  1.40      +2 -1      WebKit/WebCoreSupport.subproj/WebImageData.m
  
  Index: WebImageData.m
  ===================================================================
  RCS file: /cvs/root/WebKit/WebCoreSupport.subproj/WebImageData.m,v
  retrieving revision 1.39
  retrieving revision 1.40
  diff -u -r1.39 -r1.40
  --- WebImageData.m	20 Jul 2005 20:36:38 -0000	1.39
  +++ WebImageData.m	22 Jul 2005 00:02:23 -0000	1.40
  @@ -293,7 +293,8 @@
       if( image && CGImageGetWidth(image)==1 && CGImageGetHeight(image)==1 ) {
           float pixel[4]; // RGBA
           CGColorSpaceRef space = CGColorSpaceCreateDeviceRGB();
  -#if __i386__	
  +// This #ifdef won't be needed once the CG header that includes kCGBitmapByteOrder32Host is included in the OS
  +#ifndef __ppc__	
           CGContextRef bmap = CGBitmapContextCreate(&pixel,1,1,8*sizeof(float),sizeof(pixel),space,
                                                     kCGImageAlphaPremultipliedLast | kCGBitmapFloatComponents | kCGBitmapByteOrder32Host);
   #else
  
  
  



More information about the webkit-changes mailing list