| CODENOTIFIER | HelpYou are not signed inSign in |
Project: BlueCloth
Revision: 68
Author: ged
Date: 25 Aug 2004 01:14:37
Diff at Trac: http://www.deveiate.org/projects/BlueCloth/changeset/68
Changes:- Tracked down and fixed another regexp engine overflow bug; added a new test,
datafile, and minimal testcase that illustrates it.
| ... | ...@@ -0,0 +1,37 @@ | |
| 1 | #!/usr/bin/ruby | |
| 2 | # | |
| 3 | # Tester to find a minimal case for the regexp engine overflow bug | |
| 4 | # | |
| 5 | # Time-stamp: <24-Aug-2004 22:13:35 ged> | |
| 6 | # | |
| 7 | ||
| 8 | BEGIN { | |
| 9 | $base = File::dirname( File::dirname(File::expand_path(__FILE__)) ) | |
| 10 | $LOAD_PATH.unshift "#$base/lib" | |
| 11 | ||
| 12 | require "#$base/utils.rb" | |
| 13 | include UtilityFunctions | |
| 14 | } | |
| 15 | ||
| 16 | re = %r{ | |
| 17 | (?:\n\n|\A) # Preceded by a blank line or start of doc | |
| 18 | ( # $1 = the code block | |
| 19 | (?: | |
| 20 | (?:[ ]{4} | \t) # a tab or tab-width of spaces | |
| 21 | .*\n+ # ...followed by everything up to a newline | |
| 22 | )+ | |
| 23 | ) | |
| 24 | (?=^[ ]{0,3}\S|\Z) # $2 = non-space at line-start, or end of doc | |
| 25 | }x | |
| 26 | ||
| 27 | ||
| 28 | source = File::read( "#$base/tests/data/re-overflow2.txt" ) | |
| 29 | ||
| 30 | puts "Source length: #{source.length}" | |
| 31 | ||
| 32 | try( "re-overflow" ) { | |
| 33 | source.gsub!( re ) {|match| p match} | |
| 34 | puts "Success: '%s...'" % source[0, 20] | |
| 35 | } | |
| 36 | ||
| 37 |
| ... | ...@@ -41,6 +41,15 @@ | |
| 41 | 41 | } |
| 42 | 42 | end |
| 43 | 43 | |
| 44 | def test_15_regexp_engine_overflow_bug2 | |
| 45 | contents = File::read( File::join(BaseDir,"tests/data/re-overflow2.txt") ) | |
| 46 | bcobj = BlueCloth::new( contents ) | |
| 47 | ||
| 48 | assert_nothing_raised { | |
| 49 | bcobj.to_html | |
| 50 | } | |
| 51 | end | |
| 52 | ||
| 44 | 53 | end |
| 45 | 54 | |
| 46 | 55 |
| ... | ...@@ -0,0 +1,281 @@ | |
| 1 | <strong>iFotobilder</strong> will be an iPhoto export plugin that will let you manage your Fotobilder pictures through iPhoto. | |
| 2 | ||
| 3 | ## Getting Started | |
| 4 | ||
| 5 | Since iPhoto's APIs aren't public, and because my Objective C is extremely rusty, I wanted a couple of examples of other people's plugins before I dove into this. | |
| 6 | ||
| 7 | Here's what I found: | |
| 8 | ||
| 9 | * [Writing Plugins for Cocoa][1] | |
| 10 | ||
| 11 | [1]: http://www.stone.com/The_Cocoa_Files/Writing_PlugIns.html | |
| 12 | ||
| 13 | ## The iPhoto Export API | |
| 14 | ||
| 15 | Using the `class-dump` tool, I dumped the export API: | |
| 16 | ||
| 17 | /* | |
| 18 | * Generated by class-dump 3.0. | |
| 19 | * | |
| 20 | * class-dump is Copyright (C) 1997-1998, 2000-2001, 2004 by Steve Nygard. | |
| 21 | */ | |
| 22 | ||
| 23 | /* | |
| 24 | * File: /Applications/iPhoto.app/Contents/MacOS/iPhoto | |
| 25 | */ | |
| 26 | ||
| 27 | @protocol ExportImageProtocol | |
| 28 | - (unsigned int)imageCount; | |
| 29 | - (BOOL)imageIsPortraitAtIndex:(unsigned int)fp20; | |
| 30 | - (struct _NSSize)imageSizeAtIndex:(unsigned int)fp16; | |
| 31 | - (unsigned int)imageFormatAtIndex:(unsigned int)fp16; | |
| 32 | - (id)imageCaptionAtIndex:(unsigned int)fp16; | |
| 33 | - (id)imagePathAtIndex:(unsigned int)fp16; | |
| 34 | - (id)thumbnailPathAtIndex:(unsigned int)fp16; | |
| 35 | - (id)imageDictionaryAtIndex:(unsigned int)fp16; | |
| 36 | - (float)imageAspectRatioAtIndex:(unsigned int)fp16; | |
| 37 | - (id)albumName; | |
| 38 | - (id)albumMusicPath; | |
| 39 | - (unsigned int)albumCount; | |
| 40 | - (unsigned int)albumPositionOfImageAtIndex:(unsigned int)fp16; | |
| 41 | - (id)window; | |
| 42 | - (void)enableControls; | |
| 43 | - (void)disableControls; | |
| 44 | - (void)clickExport; | |
| 45 | - (void)startExport; | |
| 46 | - (void)cancelExport; | |
| 47 | - (void)cancelExportBeforeBeginning; | |
| 48 | - (id)directoryPath; | |
| 49 | - (id)temporaryDirectory; | |
| 50 | - (BOOL)doesFileExist:(id)fp16; | |
| 51 | - (BOOL)doesDirectoryExist:(id)fp16; | |
| 52 | - (BOOL)createDir:(id)fp16; | |
| 53 | - (id)uniqueSubPath:(id)fp12 child:(id)fp20; | |
| 54 | - (id)makeUniquePath:(id)fp16; | |
| 55 | - (id)makeUniqueFilePath:(id)fp12 extension:(id)fp20; | |
| 56 | - (id)makeUniqueFileNameWithTime:(id)fp16; | |
| 57 | - (BOOL)makeFSSpec:(id)fp12 spec:(struct FSSpec *)fp20; | |
| 58 | - (id)pathForFSSpec:(id)fp16; | |
| 59 | - (BOOL)getFSRef:(struct FSRef *)fp12 forPath:(id)fp16 isDirectory:(BOOL)fp27; | |
| 60 | - (id)pathForFSRef:(struct FSRef *)fp16; | |
| 61 | - (unsigned long)countFiles:(id)fp12 descend:(BOOL)fp23; | |
| 62 | - (unsigned long)countFilesFromArray:(id)fp12 descend:(BOOL)fp23; | |
| 63 | - (unsigned long long)sizeAtPath:(id)fp12 count:(unsigned long *)fp16 physical:(BOOL)fp27; | |
| 64 | - (BOOL)isAliasFileAtPath:(id)fp16; | |
| 65 | - (id)pathContentOfAliasAtPath:(id)fp16; | |
| 66 | - (id)stringByResolvingAliasesInPath:(id)fp16; | |
| 67 | - (BOOL)ensurePermissions:(unsigned long)fp12 forPath:(id)fp20; | |
| 68 | - (id)validFilename:(id)fp16; | |
| 69 | - (id)getExtensionForImageFormat:(unsigned int)fp16; | |
| 70 | - (unsigned int)getImageFormatForExtension:(id)fp16; | |
| 71 | - (struct OpaqueGrafPtr *)uncompressImage:(id)fp12 size:(struct _NSSize)fp16 pixelFormat:(unsigned int)fp24 rotation:(float)fp32; | |
| 72 | - (void *)createThumbnailer; | |
| 73 | - (void *)retainThumbnailer:(void *)fp16; | |
| 74 | - (void *)autoreleaseThumbnailer:(void *)fp16; | |
| 75 | - (void)releaseThumbnailer:(void *)fp16; | |
| 76 | - (void)setThumbnailer:(void *)fp16 maxBytes:(unsigned int)fp20 maxWidth:(unsigned int)fp24 maxHeight:(unsigned int)fp32; | |
| 77 | - (struct _NSSize)thumbnailerMaxBounds:(void *)fp16; | |
| 78 | - (void)setThumbnailer:(void *)fp12 quality:(int)fp20; | |
| 79 | - (int)thumbnailerQuality:(void *)fp16; | |
| 80 | - (void)setThumbnailer:(void *)fp12 rotation:(float)fp20; | |
| 81 | - (float)thumbnailerRotation:(void *)fp16; | |
| 82 | - (void)setThumbnailer:(void *)fp12 outputFormat:(unsigned int)fp20; | |
| 83 | - (unsigned int)thumbnailerOutputFormat:(void *)fp16; | |
| 84 | - (void)setThumbnailer:(void *)fp12 outputExtension:(id)fp20; | |
| 85 | - (id)thumbnailerOutputExtension:(void *)fp16; | |
| 86 | - (BOOL)thumbnailer:(void *)fp16 createThumbnail:(id)fp20 dest:(id)fp28; | |
| 87 | - (struct _NSSize)lastImageSize:(void *)fp20; | |
| 88 | - (struct _NSSize)lastThumbnailSize:(void *)fp16; | |
| 89 | @end | |
| 90 | ||
| 91 | @protocol ExportPluginBoxProtocol | |
| 92 | - (BOOL)performKeyEquivalent:(id)fp16; | |
| 93 | @end | |
| 94 | ||
| 95 | @protocol ExportPluginProtocol | |
| 96 | - (id)initWithExportImageObj:(id)fp16; | |
| 97 | - (id)settingsView; | |
| 98 | - (id)firstView; | |
| 99 | - (id)lastView; | |
| 100 | - (void)viewWillBeActivated; | |
| 101 | - (void)viewWillBeDeactivated; | |
| 102 | - (id)requiredFileType; | |
| 103 | - (BOOL)wantsDestinationPrompt; | |
| 104 | - (id)getDestinationPath; | |
| 105 | - (id)defaultFileName; | |
| 106 | - (id)defaultDirectory; | |
| 107 | - (BOOL)treatSingleSelectionDifferently; | |
| 108 | - (BOOL)validateUserCreatedPath:(id)fp16; | |
| 109 | - (void)clickExport; | |
| 110 | - (void)startExport:(id)fp16; | |
| 111 | - (void)performExport:(id)fp16; | |
| 112 | - (CDAnonymousStruct12 *)progress; | |
| 113 | - (void)lockProgress; | |
| 114 | - (void)unlockProgress; | |
| 115 | - (void)cancelExport; | |
| 116 | - (id)name; | |
| 117 | - (id)description; | |
| 118 | @end | |
| 119 | ||
| 120 | @interface ExportController : NSObject | |
| 121 | { | |
| 122 | id mWindow; | |
| 123 | id mExportView; | |
| 124 | id mExportButton; | |
| 125 | id mImageCount; | |
| 126 | ExportMgr *mExportMgr; | |
| 127 | ExportMgrRec *mCurrentPluginRec; | |
| 128 | ProgressController *mProgressController; | |
| 129 | BOOL mCancelExport; | |
| 130 | NSTimer *mTimer; | |
| 131 | NSString *mDirectoryPath; | |
| 132 | } | |
| 133 | ||
| 134 | - (void)awakeFromNib; | |
| 135 | - (void)dealloc; | |
| 136 | - (id)currentPlugin; | |
| 137 | - (id)currentPluginRec; | |
| 138 | - (void)setCurrentPluginRec:(id)fp12; | |
| 139 | - (id)directoryPath; | |
| 140 | - (void)setDirectoryPath:(id)fp12; | |
| 141 | - (void)show; | |
| 142 | - (void)_openPanelDidEnd:(id)fp12 returnCode:(int)fp16 contextInfo:(void *)fp20; | |
| 143 | - (id)panel:(id)fp12 userEnteredFilename:(id)fp16 confirmed:(BOOL)fp20; | |
| 144 | - (BOOL)panel:(id)fp12 shouldShowFilename:(id)fp16; | |
| 145 | - (BOOL)panel:(id)fp12 isValidFilename:(id)fp16; | |
| 146 | - (BOOL)filesWillFitOnDisk; | |
| 147 | - (void)export:(id)fp12; | |
| 148 | - (void)_exportThread:(id)fp12; | |
| 149 | - (void)_exportProgress:(id)fp12; | |
| 150 | - (void)startExport:(id)fp12; | |
| 151 | - (void)finishExport; | |
| 152 | - (void)cancelExport; | |
| 153 | - (void)cancel:(id)fp12; | |
| 154 | - (void)enableControls; | |
| 155 | - (id)window; | |
| 156 | - (void)disableControls; | |
| 157 | - (void)tabView:(id)fp12 willSelectTabViewItem:(id)fp16; | |
| 158 | - (void)tabView:(id)fp12 didSelectTabViewItem:(id)fp16; | |
| 159 | - (void)selectExporter:(id)fp12; | |
| 160 | - (id)exportView; | |
| 161 | - (BOOL)_hasPlugins; | |
| 162 | - (void)_resizeExporterToFitView:(id)fp12; | |
| 163 | - (void)_updateImageCount; | |
| 164 | ||
| 165 | @end | |
| 166 | ||
| 167 | @interface ExportMgr : NSObject <ExportImageProtocol> | |
| 168 | { | |
| 169 | ArchiveDocument *mDocument; | |
| 170 | NSMutableArray *mExporters; | |
| 171 | Album *mExportAlbum; | |
| 172 | NSArray *mSelection; | |
| 173 | ExportController *mExportController; | |
| 174 | } | |
| 175 | ||
| 176 | + (id)exportMgr; | |
| 177 | + (id)exportMgrNoAlloc; | |
| 178 | - (id)init; | |
| 179 | - (void)dealloc; | |
| 180 | - (void)releasePlugins; | |
| 181 | - (void)setExportController:(id)fp12; | |
| 182 | - (id)exportController; | |
| 183 | - (void)setDocument:(id)fp12; | |
| 184 | - (id)document; | |
| 185 | - (void)updateDocumentSelection; | |
| 186 | - (unsigned int)count; | |
| 187 | - (id)recAtIndex:(unsigned int)fp12; | |
| 188 | - (void)scanForExporters; | |
| 189 | - (unsigned int)imageCount; | |
| 190 | - (BOOL)imageIsPortraitAtIndex:(unsigned int)fp12; | |
| 191 | - (id)imagePathAtIndex:(unsigned int)fp12; | |
| 192 | - (struct _NSSize)imageSizeAtIndex:(unsigned int)fp16; | |
| 193 | - (unsigned int)imageFormatAtIndex:(unsigned int)fp12; | |
| 194 | - (id)imageCaptionAtIndex:(unsigned int)fp12; | |
| 195 | - (id)thumbnailPathAtIndex:(unsigned int)fp12; | |
| 196 | - (id)imageDictionaryAtIndex:(unsigned int)fp12; | |
| 197 | - (float)imageAspectRatioAtIndex:(unsigned int)fp12; | |
| 198 | - (id)albumName; | |
| 199 | - (id)albumMusicPath; | |
| 200 | - (unsigned int)albumCount; | |
| 201 | - (unsigned int)albumPositionOfImageAtIndex:(unsigned int)fp12; | |
| 202 | - (id)imageRecAtIndex:(unsigned int)fp12; | |
| 203 | - (id)currentAlbum; | |
| 204 | - (void)enableControls; | |
| 205 | - (void)disableControls; | |
| 206 | - (id)window; | |
| 207 | - (void)clickExport; | |
| 208 | - (void)startExport; | |
| 209 | - (void)cancelExport; | |
| 210 | - (void)cancelExportBeforeBeginning; | |
| 211 | - (id)directoryPath; | |
| 212 | - (void)_copySelection:(id)fp12; | |
| 213 | - (id)temporaryDirectory; | |
| 214 | - (BOOL)doesFileExist:(id)fp12; | |
| 215 | - (BOOL)doesDirectoryExist:(id)fp12; | |
| 216 | - (BOOL)createDir:(id)fp12; | |
| 217 | - (id)uniqueSubPath:(id)fp12 child:(id)fp16; | |
| 218 | - (id)makeUniquePath:(id)fp12; | |
| 219 | - (id)makeUniqueFilePath:(id)fp12 extension:(id)fp16; | |
| 220 | - (id)makeUniqueFileNameWithTime:(id)fp12; | |
| 221 | - (BOOL)makeFSSpec:(id)fp12 spec:(struct FSSpec *)fp16; | |
| 222 | - (id)pathForFSSpec:(id)fp12; | |
| 223 | - (BOOL)getFSRef:(struct FSRef *)fp12 forPath:(id)fp16 isDirectory:(BOOL)fp20; | |
| 224 | - (id)pathForFSRef:(struct FSRef *)fp12; | |
| 225 | - (unsigned long)countFiles:(id)fp12 descend:(BOOL)fp16; | |
| 226 | - (unsigned long)countFilesFromArray:(id)fp12 descend:(BOOL)fp16; | |
| 227 | - (unsigned long long)sizeAtPath:(id)fp12 count:(unsigned long *)fp16 physical:(BOOL)fp20; | |
| 228 | - (BOOL)isAliasFileAtPath:(id)fp12; | |
| 229 | - (id)pathContentOfAliasAtPath:(id)fp12; | |
| 230 | - (id)stringByResolvingAliasesInPath:(id)fp12; | |
| 231 | - (BOOL)ensurePermissions:(unsigned long)fp12 forPath:(id)fp16; | |
| 232 | - (id)validFilename:(id)fp12; | |
| 233 | - (id)getExtensionForImageFormat:(unsigned int)fp12; | |
| 234 | - (unsigned int)getImageFormatForExtension:(id)fp12; | |
| 235 | - (struct OpaqueGrafPtr *)uncompressImage:(id)fp12 size:(struct _NSSize)fp16 pixelFormat:(unsigned int)fp24 rotation:(float)fp36; | |
| 236 | - (void *)createThumbnailer; | |
| 237 | - (void *)retainThumbnailer:(void *)fp12; | |
| 238 | - (void *)autoreleaseThumbnailer:(void *)fp12; | |
| 239 | - (void)releaseThumbnailer:(void *)fp12; | |
| 240 | - (void)setThumbnailer:(void *)fp12 maxBytes:(unsigned int)fp16 maxWidth:(unsigned int)fp20 maxHeight:(unsigned int)fp24; | |
| 241 | - (struct _NSSize)thumbnailerMaxBounds:(void *)fp16; | |
| 242 | - (void)setThumbnailer:(void *)fp12 quality:(int)fp16; | |
| 243 | - (int)thumbnailerQuality:(void *)fp12; | |
| 244 | - (void)setThumbnailer:(void *)fp12 rotation:(float)fp36; | |
| 245 | - (float)thumbnailerRotation:(void *)fp12; | |
| 246 | - (void)setThumbnailer:(void *)fp12 outputFormat:(unsigned int)fp16; | |
| 247 | - (unsigned int)thumbnailerOutputFormat:(void *)fp12; | |
| 248 | - (void)setThumbnailer:(void *)fp12 outputExtension:(id)fp16; | |
| 249 | - (id)thumbnailerOutputExtension:(void *)fp12; | |
| 250 | - (BOOL)thumbnailer:(void *)fp12 createThumbnail:(id)fp16 dest:(id)fp20; | |
| 251 | - (struct _NSSize)lastImageSize:(void *)fp16; | |
| 252 | - (struct _NSSize)lastThumbnailSize:(void *)fp16; | |
| 253 | ||
| 254 | @end | |
| 255 | ||
| 256 | @interface ExportMgrRec : NSObject | |
| 257 | { | |
| 258 | NSString *mPath; | |
| 259 | NSBundle *mBundle; | |
| 260 | id mPlugin; | |
| 261 | struct _NSSize mViewSize; | |
| 262 | } | |
| 263 | ||
| 264 | - (void)dealloc; | |
| 265 | - (BOOL)isEqual:(id)fp12; | |
| 266 | - (id)description; | |
| 267 | - (id)initWithPath:(id)fp12; | |
| 268 | - (id)path; | |
| 269 | - (id)bundle; | |
| 270 | - (id)bundleInfo; | |
| 271 | - (BOOL)isValidExportPlugin; | |
| 272 | - (BOOL)loadPlugin; | |
| 273 | - (id)exportPlugin; | |
| 274 | - (void)unloadPlugin; | |
| 275 | - (id)view; | |
| 276 | - (struct _NSSize)viewSize; | |
| 277 | - (void)setPath:(id)fp12; | |
| 278 | - (void)setBundle:(id)fp12; | |
| 279 | ||
| 280 | @end | |
| 281 |
| ... | ...@@ -546,7 +546,7 @@ | |
| 546 | 546 | .*\n+ |
| 547 | 547 | )+ |
| 548 | 548 | ) |
| 549 | ((?=^[ ]{0,#{TabWidth}}\S)|\Z) # Lookahead for non-space at | |
| 549 | (^[ ]{0,#{TabWidth - 1}}\S|\Z) # Lookahead for non-space at | |
| 550 | 550 | # line-start, or end of doc |
| 551 | 551 | }x |
| 552 | 552 |