Fixing bug 156893: strip control characters out of strings which are to become bookmark titles, to avoid saving corrupt XML.

This commit is contained in:
sfraser%netscape.com 2002-07-27 01:24:42 +00:00
Родитель a4fc30822e
Коммит 217b99dddb
12 изменённых файлов: 76 добавлений и 64 удалений

Просмотреть файл

@ -37,6 +37,8 @@
*
* ***** END LICENSE BLOCK ***** */
#import "NSString+Utils.h"
#import "BookmarksDataSource.h"
#import "BookmarkInfoController.h"
@ -150,12 +152,15 @@
} else { // Folder
mCachedHref = nil;
title = NS_LITERAL_STRING("New Folder");
title = NS_LITERAL_STRING("New Folder"); // XXX localize me
}
NSTextField* textField = [mBrowserWindowController getAddBookmarkTitle];
[textField setStringValue: [NSString stringWithCharacters: title.get() length: title.Length()]];
NSTextField* textField = [mBrowserWindowController getAddBookmarkTitle];
NSString* bookmarkTitle = [NSString stringWithCharacters: title.get() length: title.Length()];
NSString* cleanedTitle = [bookmarkTitle stringByReplacingCharactersInSet:[NSCharacterSet controlCharacterSet] withString:@" "];
[textField setStringValue: cleanedTitle];
[mBrowserWindowController cacheBookmarkDS: self];
// Show/hide the bookmark all tabs checkbox as appropriate.

Просмотреть файл

@ -21,9 +21,12 @@
* Joe Hewitt <hewitt@netscape.com> (Original Author)
*/
#import "NSString+Utils.h"
#import "CHPageProxyIcon.h"
#import "BookmarksService.h"
#import "MainController.h"
#include "nsCRT.h"
@implementation CHPageProxyIcon
@ -50,25 +53,20 @@
- (void) mouseDragged: (NSEvent*) event
{
NSPasteboard *pboard;
NSDictionary* data;
NSArray* dataVals;
NSArray* dataKeys;
NSString* url;
NSString* title;
nsAutoString hrefStr, titleStr;
BookmarksService::GetTitleAndHrefForBrowserView(
[[[[self window] windowController] getBrowserWrapper] getBrowserView], titleStr, hrefStr);
url = [NSString stringWithCharacters: hrefStr.get() length: nsCRT::strlen(hrefStr.get())];
title = [NSString stringWithCharacters: titleStr.get() length: nsCRT::strlen(titleStr.get())];
NSString *url = [NSString stringWithCharacters: hrefStr.get() length: nsCRT::strlen(hrefStr.get())];
NSString *title = [NSString stringWithCharacters: titleStr.get() length: nsCRT::strlen(titleStr.get())];
dataVals = [NSArray arrayWithObjects: url, title, nil];
dataKeys = [NSArray arrayWithObjects: @"url", @"title", nil];
data = [NSDictionary dictionaryWithObjects:dataVals forKeys:dataKeys];
NSString *cleanedTitle = [title stringByReplacingCharactersInSet:[NSCharacterSet controlCharacterSet] withString:@" "];
pboard = [NSPasteboard pasteboardWithName:NSDragPboard];
NSArray *dataVals = [NSArray arrayWithObjects: url, cleanedTitle, nil];
NSArray *dataKeys = [NSArray arrayWithObjects: @"url", @"title", nil];
NSDictionary *data = [NSDictionary dictionaryWithObjects:dataVals forKeys:dataKeys];
NSPasteboard *pboard = [NSPasteboard pasteboardWithName:NSDragPboard];
[pboard declareTypes:[NSArray arrayWithObjects:@"MozURLType", NSURLPboardType, NSStringPboardType, nil] owner:self];
[pboard setPropertyList:data forType: @"MozURLType"];
[[NSURL URLWithString:url] writeToPasteboard: pboard];

Двоичные данные
camino/English.lproj/Localizable.strings

Двоичный файл не отображается.

Двоичный файл не отображается.

Просмотреть файл

@ -37,6 +37,8 @@
*
* ***** END LICENSE BLOCK ***** */
#import "NSString+Utils.h"
#import "BookmarksDataSource.h"
#import "BookmarkInfoController.h"
@ -150,12 +152,15 @@
} else { // Folder
mCachedHref = nil;
title = NS_LITERAL_STRING("New Folder");
title = NS_LITERAL_STRING("New Folder"); // XXX localize me
}
NSTextField* textField = [mBrowserWindowController getAddBookmarkTitle];
[textField setStringValue: [NSString stringWithCharacters: title.get() length: title.Length()]];
NSTextField* textField = [mBrowserWindowController getAddBookmarkTitle];
NSString* bookmarkTitle = [NSString stringWithCharacters: title.get() length: title.Length()];
NSString* cleanedTitle = [bookmarkTitle stringByReplacingCharactersInSet:[NSCharacterSet controlCharacterSet] withString:@" "];
[textField setStringValue: cleanedTitle];
[mBrowserWindowController cacheBookmarkDS: self];
// Show/hide the bookmark all tabs checkbox as appropriate.

Просмотреть файл

@ -21,9 +21,12 @@
* Joe Hewitt <hewitt@netscape.com> (Original Author)
*/
#import "NSString+Utils.h"
#import "CHPageProxyIcon.h"
#import "BookmarksService.h"
#import "MainController.h"
#include "nsCRT.h"
@implementation CHPageProxyIcon
@ -50,25 +53,20 @@
- (void) mouseDragged: (NSEvent*) event
{
NSPasteboard *pboard;
NSDictionary* data;
NSArray* dataVals;
NSArray* dataKeys;
NSString* url;
NSString* title;
nsAutoString hrefStr, titleStr;
BookmarksService::GetTitleAndHrefForBrowserView(
[[[[self window] windowController] getBrowserWrapper] getBrowserView], titleStr, hrefStr);
url = [NSString stringWithCharacters: hrefStr.get() length: nsCRT::strlen(hrefStr.get())];
title = [NSString stringWithCharacters: titleStr.get() length: nsCRT::strlen(titleStr.get())];
NSString *url = [NSString stringWithCharacters: hrefStr.get() length: nsCRT::strlen(hrefStr.get())];
NSString *title = [NSString stringWithCharacters: titleStr.get() length: nsCRT::strlen(titleStr.get())];
dataVals = [NSArray arrayWithObjects: url, title, nil];
dataKeys = [NSArray arrayWithObjects: @"url", @"title", nil];
data = [NSDictionary dictionaryWithObjects:dataVals forKeys:dataKeys];
NSString *cleanedTitle = [title stringByReplacingCharactersInSet:[NSCharacterSet controlCharacterSet] withString:@" "];
pboard = [NSPasteboard pasteboardWithName:NSDragPboard];
NSArray *dataVals = [NSArray arrayWithObjects: url, cleanedTitle, nil];
NSArray *dataKeys = [NSArray arrayWithObjects: @"url", @"title", nil];
NSDictionary *data = [NSDictionary dictionaryWithObjects:dataVals forKeys:dataKeys];
NSPasteboard *pboard = [NSPasteboard pasteboardWithName:NSDragPboard];
[pboard declareTypes:[NSArray arrayWithObjects:@"MozURLType", NSURLPboardType, NSStringPboardType, nil] owner:self];
[pboard setPropertyList:data forType: @"MozURLType"];
[[NSURL URLWithString:url] writeToPasteboard: pboard];

Просмотреть файл

@ -37,6 +37,8 @@
*
* ***** END LICENSE BLOCK ***** */
#import "NSString+Utils.h"
#import "BookmarksDataSource.h"
#import "BookmarkInfoController.h"
@ -150,12 +152,15 @@
} else { // Folder
mCachedHref = nil;
title = NS_LITERAL_STRING("New Folder");
title = NS_LITERAL_STRING("New Folder"); // XXX localize me
}
NSTextField* textField = [mBrowserWindowController getAddBookmarkTitle];
[textField setStringValue: [NSString stringWithCharacters: title.get() length: title.Length()]];
NSTextField* textField = [mBrowserWindowController getAddBookmarkTitle];
NSString* bookmarkTitle = [NSString stringWithCharacters: title.get() length: title.Length()];
NSString* cleanedTitle = [bookmarkTitle stringByReplacingCharactersInSet:[NSCharacterSet controlCharacterSet] withString:@" "];
[textField setStringValue: cleanedTitle];
[mBrowserWindowController cacheBookmarkDS: self];
// Show/hide the bookmark all tabs checkbox as appropriate.

Просмотреть файл

@ -21,9 +21,12 @@
* Joe Hewitt <hewitt@netscape.com> (Original Author)
*/
#import "NSString+Utils.h"
#import "CHPageProxyIcon.h"
#import "BookmarksService.h"
#import "MainController.h"
#include "nsCRT.h"
@implementation CHPageProxyIcon
@ -50,25 +53,20 @@
- (void) mouseDragged: (NSEvent*) event
{
NSPasteboard *pboard;
NSDictionary* data;
NSArray* dataVals;
NSArray* dataKeys;
NSString* url;
NSString* title;
nsAutoString hrefStr, titleStr;
BookmarksService::GetTitleAndHrefForBrowserView(
[[[[self window] windowController] getBrowserWrapper] getBrowserView], titleStr, hrefStr);
url = [NSString stringWithCharacters: hrefStr.get() length: nsCRT::strlen(hrefStr.get())];
title = [NSString stringWithCharacters: titleStr.get() length: nsCRT::strlen(titleStr.get())];
NSString *url = [NSString stringWithCharacters: hrefStr.get() length: nsCRT::strlen(hrefStr.get())];
NSString *title = [NSString stringWithCharacters: titleStr.get() length: nsCRT::strlen(titleStr.get())];
dataVals = [NSArray arrayWithObjects: url, title, nil];
dataKeys = [NSArray arrayWithObjects: @"url", @"title", nil];
data = [NSDictionary dictionaryWithObjects:dataVals forKeys:dataKeys];
NSString *cleanedTitle = [title stringByReplacingCharactersInSet:[NSCharacterSet controlCharacterSet] withString:@" "];
pboard = [NSPasteboard pasteboardWithName:NSDragPboard];
NSArray *dataVals = [NSArray arrayWithObjects: url, cleanedTitle, nil];
NSArray *dataKeys = [NSArray arrayWithObjects: @"url", @"title", nil];
NSDictionary *data = [NSDictionary dictionaryWithObjects:dataVals forKeys:dataKeys];
NSPasteboard *pboard = [NSPasteboard pasteboardWithName:NSDragPboard];
[pboard declareTypes:[NSArray arrayWithObjects:@"MozURLType", NSURLPboardType, NSStringPboardType, nil] owner:self];
[pboard setPropertyList:data forType: @"MozURLType"];
[[NSURL URLWithString:url] writeToPasteboard: pboard];

Двоичные данные
chimera/English.lproj/Localizable.strings

Двоичный файл не отображается.

Двоичный файл не отображается.

Просмотреть файл

@ -37,6 +37,8 @@
*
* ***** END LICENSE BLOCK ***** */
#import "NSString+Utils.h"
#import "BookmarksDataSource.h"
#import "BookmarkInfoController.h"
@ -150,12 +152,15 @@
} else { // Folder
mCachedHref = nil;
title = NS_LITERAL_STRING("New Folder");
title = NS_LITERAL_STRING("New Folder"); // XXX localize me
}
NSTextField* textField = [mBrowserWindowController getAddBookmarkTitle];
[textField setStringValue: [NSString stringWithCharacters: title.get() length: title.Length()]];
NSTextField* textField = [mBrowserWindowController getAddBookmarkTitle];
NSString* bookmarkTitle = [NSString stringWithCharacters: title.get() length: title.Length()];
NSString* cleanedTitle = [bookmarkTitle stringByReplacingCharactersInSet:[NSCharacterSet controlCharacterSet] withString:@" "];
[textField setStringValue: cleanedTitle];
[mBrowserWindowController cacheBookmarkDS: self];
// Show/hide the bookmark all tabs checkbox as appropriate.

Просмотреть файл

@ -21,9 +21,12 @@
* Joe Hewitt <hewitt@netscape.com> (Original Author)
*/
#import "NSString+Utils.h"
#import "CHPageProxyIcon.h"
#import "BookmarksService.h"
#import "MainController.h"
#include "nsCRT.h"
@implementation CHPageProxyIcon
@ -50,25 +53,20 @@
- (void) mouseDragged: (NSEvent*) event
{
NSPasteboard *pboard;
NSDictionary* data;
NSArray* dataVals;
NSArray* dataKeys;
NSString* url;
NSString* title;
nsAutoString hrefStr, titleStr;
BookmarksService::GetTitleAndHrefForBrowserView(
[[[[self window] windowController] getBrowserWrapper] getBrowserView], titleStr, hrefStr);
url = [NSString stringWithCharacters: hrefStr.get() length: nsCRT::strlen(hrefStr.get())];
title = [NSString stringWithCharacters: titleStr.get() length: nsCRT::strlen(titleStr.get())];
NSString *url = [NSString stringWithCharacters: hrefStr.get() length: nsCRT::strlen(hrefStr.get())];
NSString *title = [NSString stringWithCharacters: titleStr.get() length: nsCRT::strlen(titleStr.get())];
dataVals = [NSArray arrayWithObjects: url, title, nil];
dataKeys = [NSArray arrayWithObjects: @"url", @"title", nil];
data = [NSDictionary dictionaryWithObjects:dataVals forKeys:dataKeys];
NSString *cleanedTitle = [title stringByReplacingCharactersInSet:[NSCharacterSet controlCharacterSet] withString:@" "];
pboard = [NSPasteboard pasteboardWithName:NSDragPboard];
NSArray *dataVals = [NSArray arrayWithObjects: url, cleanedTitle, nil];
NSArray *dataKeys = [NSArray arrayWithObjects: @"url", @"title", nil];
NSDictionary *data = [NSDictionary dictionaryWithObjects:dataVals forKeys:dataKeys];
NSPasteboard *pboard = [NSPasteboard pasteboardWithName:NSDragPboard];
[pboard declareTypes:[NSArray arrayWithObjects:@"MozURLType", NSURLPboardType, NSStringPboardType, nil] owner:self];
[pboard setPropertyList:data forType: @"MozURLType"];
[[NSURL URLWithString:url] writeToPasteboard: pboard];