Revision: 29798
http://sourceforge.net/p/bibdesk/svn/29798
Author: hofman
Date: 2025-11-14 10:40:32 +0000 (Fri, 14 Nov 2025)
Log Message:
-----------
Class method for classes allowed for secure decoding of column values of tree
node class. Use subclass for file matcher to provide classes we use.
Modified Paths:
--------------
trunk/bibdesk/BDSKFileMatcher.m
trunk/bibdesk/BDSKTreeNode.m
Modified: trunk/bibdesk/BDSKFileMatcher.m
===================================================================
--- trunk/bibdesk/BDSKFileMatcher.m 2025-11-14 10:17:33 UTC (rev 29797)
+++ trunk/bibdesk/BDSKFileMatcher.m 2025-11-14 10:40:32 UTC (rev 29798)
@@ -73,7 +73,7 @@
#define SCORE_KEY @"score"
#define CHILDREN_KEY @"children"
-@interface BDSKTreeNode (BDSKQuickLook) <QLPreviewItem>
+@interface BDSKMatchedFileNode : BDSKTreeNode <QLPreviewItem>
@end
@interface BDSKFileMatcher ()
@@ -397,7 +397,7 @@
NSMutableArray *nodes = [[NSMutableArray alloc] init];
for (BibItem *pub in pubs) {
- BDSKTreeNode *theNode = [[BDSKTreeNode alloc] init];
+ BDSKTreeNode *theNode = [[BDSKMatchedFileNode alloc] init];
// we add the pub to the tree so it's retained, but don't touch it in
the thread!
[theNode setValue:pub forKey:PUB_KEY];
@@ -478,7 +478,7 @@
// now we have a matching file; we could remove it from
the index, but multiple matches are reasonable
for (i = 0; i < iMax; i++) {
- BDSKTreeNode *child = [[BDSKTreeNode alloc] init];
+ BDSKTreeNode *child = [[BDSKMatchedFileNode alloc]
init];
[child setValue:(__bridge NSURL *)urls[i]
forKey:FILEURL_KEY];
[child setValue:[[(__bridge NSURL *)urls[i] path]
stringByAbbreviatingWithTildeInPath] forKey:STRING_KEY];
[child setValue:[[NSWorkspace sharedWorkspace]
iconForFile:[(__bridge NSURL *)urls[i] path]] forKey:IMAGE_KEY];
@@ -615,8 +615,12 @@
@end
-@implementation BDSKTreeNode (BDSKQuickLook)
+@implementation BDSKMatchedFileNode
++ (NSSet *)allowedColumnValueClasses {
+ return [NSSet setWithObjects:[NSDictionary class], [NSString class],
[NSNumber class], [NSURL class], [NSImage class], [BibItem class], nil];
+}
+
- (NSURL *)previewItemURL {
return [self valueForKey:FILEURL_KEY];
}
Modified: trunk/bibdesk/BDSKTreeNode.m
===================================================================
--- trunk/bibdesk/BDSKTreeNode.m 2025-11-14 10:17:33 UTC (rev 29797)
+++ trunk/bibdesk/BDSKTreeNode.m 2025-11-14 10:40:32 UTC (rev 29798)
@@ -37,6 +37,7 @@
*/
#import "BDSKTreeNode.h"
+#import "BibItem.h"
@implementation BDSKTreeNode
@@ -65,11 +66,15 @@
return [NSString stringWithFormat:@"%@: %@ parent object;\n\tvalues:
\"%@\"\n\tchildren: \"%@\"", [super description], parent?@"Has":@"No",
columnValues, children];
}
++ (NSSet *)allowedColumnValueClasses {
+ return [NSSet setWithObjects:[NSDictionary class], [NSString class],
[NSData class], nil];
+}
+
- (instancetype)initWithCoder:(NSCoder *)coder;
{
if(self = [super init]){
children = [[NSMutableArray alloc] initWithArray:[coder
decodeObjectOfClasses:[NSSet setWithObjects:[NSArray class], [BDSKTreeNode
class], nil] forKey:@"children"]];
- columnValues = [[NSMutableDictionary alloc] initWithDictionary:[coder
decodeObjectOfClasses:[NSSet setWithObjects:[NSDictionary class], [NSString
class], [NSNumber class], [NSURL class], [NSData class], nil]
forKey:@"columnValues"]];
+ columnValues = [[NSMutableDictionary alloc] initWithDictionary:[coder
decodeObjectOfClasses:[[self class] allowedColumnValueClasses]
forKey:@"columnValues"]];
parent = [coder decodeObjectOfClass:[BDSKTreeNode class]
forKey:@"parent"];
}
return self;
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
_______________________________________________
Bibdesk-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bibdesk-commit