Skip to content

Commit 4046881

Browse files
mgmartwebframp
authored andcommitted
Bug fix/#59&#61 (#119)
* General cleanup - not related to the fix * Fixes #59 and Fixes #61 at least for Dropbox. Not tested with WebDAV * Wrong regex was committed * Added simple test
1 parent a0deef1 commit 4046881

12 files changed

Lines changed: 153 additions & 373 deletions

Classes/DataModel/Node.m

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ @implementation Node
4545
@dynamic notes;
4646
@dynamic children;
4747

48-
static NSString *kFileLinkRegex = @"\\[\\[file:([a-zA-Z0-9/\\-_\\.]*\\.(?:org|txt))\\]\\[(.*)\\]\\]";
48+
static NSString *kUnixFileLinkRegex = @"\\[\\[file:(.*\\.(?:org|txt))\\]\\[(.*)\\]\\]";
49+
4950

5051
- (NSComparisonResult)sequenceIndexCompare:(Node*)obj
5152
{
@@ -311,7 +312,7 @@ - (NSString*)resolveLink:(NSString*)link {
311312
}
312313

313314
- (bool)isLink {
314-
NSRange linkRange = [[self heading] rangeOfRegex:kFileLinkRegex];
315+
NSRange linkRange = [[self heading] rangeOfRegex:kUnixFileLinkRegex];
315316
if (linkRange.location != NSNotFound) {
316317
return true;
317318
}
@@ -320,7 +321,7 @@ - (bool)isLink {
320321

321322
// This will construct the link relative to the root of the file, sort of. It isn't perfect yet.
322323
- (NSString*)linkFile {
323-
NSArray *captures = [[self heading] captureComponentsMatchedByRegex:kFileLinkRegex];
324+
NSArray *captures = [[self heading] captureComponentsMatchedByRegex:kUnixFileLinkRegex];
324325
if ([captures count] > 0) {
325326
return [self resolveLink:[captures objectAtIndex:1]];
326327
}
@@ -360,7 +361,7 @@ - (void)collectLinks:(NSMutableArray*)links {
360361

361362
// Collect links from body text
362363
{
363-
NSArray *matches = [[self body] arrayOfCaptureComponentsMatchedByRegex:kFileLinkRegex];
364+
NSArray *matches = [[self body] arrayOfCaptureComponentsMatchedByRegex:kUnixFileLinkRegex];
364365
for (NSArray *match in matches) {
365366
NSString *link = [self resolveLink:[match objectAtIndex:1]];
366367
if (link && [link length] > 1) {
@@ -391,6 +392,7 @@ - (NSString*)markupLine:(NSString*)line {
391392

392393
// Any file: links that link to org files?
393394
{
395+
// FIXME: No Unix Filenames matched!
394396
NSString *regexString = @"\\[\\[file:([a-zA-Z0-9/\\-\\._]+\\.(?:org|txt))\\]\\[([a-zA-Z0-9/\\-_\\. '!?]+)\\]\\]";
395397
line = [line stringByReplacingOccurrencesOfRegex:regexString withString:@"<a href='orgfile:$1'>$2</a>"];
396398
}

Classes/Settings/Settings.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ - (NSURL*)baseUrl {
351351
}
352352

353353
- (NSURL*)urlForFilename:(NSString*)filename {
354-
return [NSURL URLWithString:[NSString stringWithFormat:@"%@%@", [self baseUrl], filename]];
354+
return [NSURL URLWithString:[[NSString stringWithFormat:@"%@%@", [self baseUrl], filename] stringByAddingPercentEncodingWithAllowedCharacters: [NSCharacterSet URLQueryAllowedCharacterSet]]] ;
355355
}
356356

357357
- (bool)isConfiguredProperly {

Classes/Sync/Dropbox/DropboxTransferManager.h

Lines changed: 0 additions & 55 deletions
This file was deleted.

Classes/Sync/Dropbox/DropboxTransferManager.m

Lines changed: 0 additions & 289 deletions
This file was deleted.

0 commit comments

Comments
 (0)