I have this small tool that I have been using for ages to convert
property lists into different formats to analyse them in detail.
I never thought it would be useful for anybody else, but feel free to
try it on your webarchives.

You will end up with another property list, that is just as readable by
GNUstep as was the original one. But it might be easier for you to read
the content. You will see just as Ivan described that there is one
WebMainResource plus a list of WebSubresources all consisting of the
same structure. And under the key WebResourceData of each you will find
the file content. I did not look at how these files are encoded, from
the original file I would expect them to be another binary property
list. Maybe these are in NSFileWrapper serialized format, a format the
GNustep is still missing.

Fred

Am 17.11.2014 um 16:23 schrieb Ivan Vučica:
> It's a binary plist. I'm unaware of a plist editor or converter
> targeting GNUstep as such, but I think GNUstep does support bplists.
> Hence, you should be able to write a converter/extractor yourself.
> 
> However, I'm looking at a arbitrary .webarchive I found online. I'm only
> guessing the structure and contents from viewing this file using 'less'.
> So -- and I'm only guessing -- it seems to me that files don't have a
> "local" name or ID, and aren't referenced using one. That is, HTML
> doesn't seem to be rewritten to use a local file. I would suspect that
> Safari intercepts resource loads and serves content stored in
> NSDictionary, which (if I'm guessing right) is ingenious.
> 
> It does mean a trivially 'unpacked' file will not find its local copy of
> resources.
> 
> Perhaps the right way to do this is to take a web browser apart and hack
> it to access appropriate files in the .webarchive when a resource load
> is requested. Or even to build a GNUstep browser. If you're enthusiastic
> enough, Chromium Embedded Framework sounds like a neat way to build a
> GNUstep browser.
>   https://code.google.com/p/chromiumembedded/
> 
> On Mon, Nov 17, 2014 at 2:58 PM, Gerold Rupprecht <[email protected]
> <mailto:[email protected]>> wrote:
> 
>     Hi,
> 
>     Has anyone been able to unarchive a "webarchive" formatted file?
> 
>     Apparently it is made with a Safari browser. Are there any other options
>     to installing Safari and wine to a GNU/linux machine?
> 
>     Any other advise?
> 
>     Thanks,
> 
>     Gerold
/* 
   Tester for property list conversion
   Copyright (C) 2006 Free Software Foundation, Inc.

   Written by: Fred Kiefer <[email protected]>
   Created: April 2006

   This file is part of the GNUstep Base Library.

   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Library General Public
   License as published by the Free Software Foundation; either
   version 2 of the License, or (at your option) any later version.

   This library is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   Library General Public License for more details.

   You should have received a copy of the GNU Library General Public
   License along with this library; if not, write to the Free
   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
*/
#include <Foundation/NSAutoreleasePool.h>
#include <Foundation/NSArray.h>
#include <Foundation/NSData.h>
#include <Foundation/NSDictionary.h>
#include <Foundation/NSFileHandle.h>
#include <Foundation/NSFileManager.h>
#include <Foundation/NSValue.h>
#include <Foundation/NSString.h>
#include "Foundation/NSPropertyList.h"
#include "Foundation/NSProcessInfo.h"

NSData * 
write_pl(id prop)
{
  NSString *error;
  NSData *data;
  
  data = [NSPropertyListSerialization dataFromPropertyList: prop
//				      format: NSPropertyListBinaryFormat_v1_0
				      format: NSPropertyListXMLFormat_v1_0
				      errorDescription: &error];
  return data;
}

id
read_pl(NSData *data)
{
  NSPropertyListFormat format;
  NSString *error;

  return [NSPropertyListSerialization propertyListFromData: data
				      mutabilityOption: NSPropertyListImmutable
				      format: &format
				      errorDescription: &error];
}

int main (int argc, const char *argv[])
{
  NSAutoreleasePool *pool = [NSAutoreleasePool new];
  id prop;
  NSData *inputData = nil;
  NSData *outputData;
  NSFileHandle *fileHandle = nil;
  NSProcessInfo *processInfo = [NSProcessInfo processInfo];
  NSArray *arguments = [processInfo arguments];
  int inputIndex = 0;
  int outputIndex = 0;

  // insert your code here
  inputIndex = [arguments indexOfObject: @"-input"];
  if (inputIndex == NSNotFound)
    {
      // setup the file handle.
      fileHandle = [NSFileHandle fileHandleWithStandardInput];
      // Read in the input from the file.
      inputData = [fileHandle readDataToEndOfFile];
    }
  else
    {
      // set up the file handle.
      fileHandle = [NSFileHandle fileHandleForReadingAtPath:
                                     [arguments objectAtIndex: inputIndex+1]];
      // read in the data.
      inputData = [fileHandle readDataToEndOfFile];
      [fileHandle closeFile];
    }

  prop = read_pl(inputData);
  outputData = write_pl(prop);

  outputIndex = [arguments indexOfObject: @"-output"];
  if (outputIndex == NSNotFound)
    {
      // setup the file handle.
      fileHandle = [NSFileHandle fileHandleWithStandardOutput];
      // Send the data to stdout
      [fileHandle writeData: outputData];
      puts("\n");
    }
  else
    {
      NSFileManager *fileManager = [NSFileManager defaultManager];

      [fileManager createFileAtPath: [arguments objectAtIndex: outputIndex+1]
			   contents: outputData
			 attributes: nil];
    }

  [pool release];
  return 0;
}
_______________________________________________
Discuss-gnustep mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/discuss-gnustep

Reply via email to