зеркало из https://github.com/mozilla/gecko-dev.git
fix export of html bookmarks to be a better utf8 citizen, fix importing
so that special flags are cleared during import to not conflict (bug 225769)
This commit is contained in:
Родитель
ce0b3288f3
Коммит
9ba69c036b
|
@ -606,15 +606,15 @@ static void doHTTPUpdateCallBack(CFReadStreamRef stream, CFStreamEventType type,
|
|||
for (unsigned i = 0;i<aPad;i++)
|
||||
[padString insertString:@" " atIndex:0];
|
||||
if ([mDescription length] > 0)
|
||||
formatString = @"%@<DT><A HREF=\"%s\">%s</A>\n%@<DD>%s\n";
|
||||
formatString = @"%@<DT><A HREF=\"%@\">%@</A>\n%@<DD>%@\n";
|
||||
else
|
||||
formatString = @"%@<DT><A HREF=\"%s\">%s</A>\n";
|
||||
formatString = @"%@<DT><A HREF=\"%@\">%@</A>\n";
|
||||
return [NSString stringWithFormat:formatString,
|
||||
padString,
|
||||
[[self url] UTF8String],
|
||||
[[mTitle stringByAddingAmpEscapes] UTF8String],
|
||||
[self url],
|
||||
[mTitle stringByAddingAmpEscapes],
|
||||
padString,
|
||||
[[mDescription stringByAddingAmpEscapes] UTF8String]];
|
||||
[mDescription stringByAddingAmpEscapes]];
|
||||
}
|
||||
|
||||
//
|
||||
|
|
|
@ -796,7 +796,19 @@ NSString* BookmarkFolderDockMenuChangeNotificaton = @"bf_dmc";
|
|||
[self setTitle:[aDict objectForKey:BMTitleKey]];
|
||||
[self setDescription:[aDict objectForKey:BMFolderDescKey]];
|
||||
[self setKeyword:[aDict objectForKey:BMFolderKeywordKey]];
|
||||
[self setSpecialFlag:[[aDict objectForKey:BMFolderTypeKey] unsignedIntValue]];
|
||||
unsigned int flag = [[aDict objectForKey:BMFolderTypeKey] unsignedIntValue];
|
||||
// on the off chance we've imported somebody else's bookmarks after startup,
|
||||
// we need to clear any super special flags on it. if we have a shared bookmark manager,
|
||||
// we're not in startup, so clear things out.
|
||||
if ([BookmarkManager sharedBookmarkManager]) {
|
||||
if ((flag & kBookmarkRootFolder) != 0)
|
||||
flag &= ~kBookmarkRootFolder;
|
||||
if ((flag & kBookmarkToolbarFolder) != 0)
|
||||
flag &= ~kBookmarkToolbarFolder;
|
||||
if ((flag & kBookmarkSmartFolder) != 0)
|
||||
flag &= ~kBookmarkSmartFolder;
|
||||
}
|
||||
[self setSpecialFlag:flag];
|
||||
enumerator = [[aDict objectForKey:BMChildrenKey] objectEnumerator];
|
||||
while ((aKid = [enumerator nextObject]) && noErr) {
|
||||
if ([aKid objectForKey:BMChildrenKey])
|
||||
|
@ -972,13 +984,13 @@ NSString* BookmarkFolderDockMenuChangeNotificaton = @"bf_dmc";
|
|||
formatString = @"%@<DT><H3 FOLDER_GROUP=\"true\">%@</H3>\n%@<DL><p>\n";
|
||||
else
|
||||
formatString = @"%@<DT><H3>%@</H3>\n%@<DL><p>\n";
|
||||
htmlString = [NSString stringWithFormat:formatString, padString, [NSString stringWithUTF8String:[[mTitle stringByAddingAmpEscapes] UTF8String]], padString];
|
||||
htmlString = [NSString stringWithFormat:formatString, padString,[mTitle stringByAddingAmpEscapes],padString];
|
||||
}
|
||||
// Toolbar Folder
|
||||
else if ([self isToolbar])
|
||||
htmlString = [NSString stringWithFormat:@"%@<DT><H3 PERSONAL_TOOLBAR_FOLDER=\"true\">%@</H3>\n%@<DL><p>\n",
|
||||
padString,
|
||||
[NSString stringWithUTF8String:[[mTitle stringByAddingAmpEscapes] UTF8String]],
|
||||
[mTitle stringByAddingAmpEscapes],
|
||||
padString];
|
||||
// Root Folder
|
||||
else if ([self isRoot])
|
||||
|
|
|
@ -809,10 +809,9 @@ static unsigned gFirstUserCollection = 0;
|
|||
|
||||
- (void) writeHTMLFile:(NSString *)pathToFile
|
||||
{
|
||||
NSString *htmlString = [[self rootBookmarks] writeHTML:0];
|
||||
if (![htmlString writeToFile:[pathToFile stringByStandardizingPath] atomically:YES])
|
||||
NSData *htmlData = [[[self rootBookmarks] writeHTML:0] dataUsingEncoding:NSUTF8StringEncoding];
|
||||
if (![htmlData writeToFile:[pathToFile stringByStandardizingPath] atomically:YES])
|
||||
NSLog(@"writeHTML: Failed to write file %@",pathToFile);
|
||||
return;
|
||||
}
|
||||
|
||||
-(void) writeSafariFile:(NSString *)pathToFile
|
||||
|
@ -820,15 +819,13 @@ static unsigned gFirstUserCollection = 0;
|
|||
NSDictionary* dict = [[self rootBookmarks] writeSafariDictionary];
|
||||
if (![dict writeToFile:[pathToFile stringByStandardizingPath] atomically:YES])
|
||||
NSLog(@"writeSafariFile: Failed to write file %@",pathToFile);
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
-(void)writePropertyListFile:(NSString *)pathToFile
|
||||
{
|
||||
NSDictionary* dict = [[self rootBookmarks] writeNativeDictionary];
|
||||
if (![dict writeToFile:[pathToFile stringByStandardizingPath] atomically:YES])
|
||||
NSLog(@"writePropertyList: Failed to write file %@",pathToFile);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче