mirror of
https://github.com/samuelclay/NewsBlur.git
synced 2025-09-18 21:50:56 +00:00
Removing base64 lib.
This commit is contained in:
parent
a286be68a9
commit
98537bd4f8
10 changed files with 6 additions and 144 deletions
|
@ -13,7 +13,6 @@
|
|||
#import "NBContainerViewController.h"
|
||||
#import "MenuViewController.h"
|
||||
#import "SBJson4.h"
|
||||
#import "Base64.h"
|
||||
|
||||
@interface AddSiteViewController()
|
||||
|
||||
|
@ -413,7 +412,7 @@
|
|||
NSString *favicon = [result objectForKey:@"favicon"];
|
||||
UIImage *faviconImage;
|
||||
if ((NSNull *)favicon != [NSNull null] && [favicon length] > 0) {
|
||||
NSData *imageData = [NSData dataWithBase64EncodedString:favicon];
|
||||
NSData *imageData = [[NSData alloc] initWithBase64EncodedString:favicon options:NSDataBase64DecodingIgnoreUnknownCharacters];
|
||||
faviconImage = [UIImage imageWithData:imageData];
|
||||
} else {
|
||||
faviconImage = [UIImage imageNamed:@"world.png"];
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
#import "StoryPageControl.h"
|
||||
#import "NSString+HTML.h"
|
||||
#import "MBProgressHUD.h"
|
||||
#import "Base64.h"
|
||||
#import "SBJson4.h"
|
||||
#import "NSObject+SBJSON.h"
|
||||
#import "StringHelper.h"
|
||||
|
@ -2414,7 +2413,7 @@ didEndSwipingSwipingWithState:(MCSwipeTableViewCellState)state
|
|||
|
||||
NSString *favicon = [feed objectForKey:@"favicon"];
|
||||
if ((NSNull *)favicon != [NSNull null] && [favicon length] > 0) {
|
||||
NSData *imageData = [NSData dataWithBase64EncodedString:favicon];
|
||||
NSData *imageData = [[NSData alloc] initWithBase64EncodedString:favicon options:NSDataBase64DecodingIgnoreUnknownCharacters];
|
||||
UIImage *faviconImage = [UIImage imageWithData:imageData];
|
||||
[appDelegate saveFavicon:faviconImage feedId:feed_id];
|
||||
}
|
||||
|
|
|
@ -12,7 +12,6 @@
|
|||
#import "AuthorizeServicesViewController.h"
|
||||
#import "NewsBlurViewController.h"
|
||||
#import "SiteCell.h"
|
||||
#import "Base64.h"
|
||||
|
||||
@interface FirstTimeUserAddSitesViewController()
|
||||
|
||||
|
@ -394,7 +393,7 @@
|
|||
// favicon
|
||||
|
||||
NSString *faviconStr = [NSString stringWithFormat:@"%@", [feed valueForKey:@"favicon"]];
|
||||
NSData *imageData = [NSData dataWithBase64EncodedString:faviconStr];
|
||||
NSData *imageData = [[NSData alloc] initWithBase64EncodedString:faviconStr options:NSDataBase64DecodingIgnoreUnknownCharacters];
|
||||
UIImage *faviconImage = [UIImage imageWithData:imageData];
|
||||
|
||||
|
||||
|
|
|
@ -21,7 +21,6 @@
|
|||
#import "StoryDetailViewController.h"
|
||||
#import "StoryPageControl.h"
|
||||
#import "MBProgressHUD.h"
|
||||
#import "Base64.h"
|
||||
#import "SBJson4.h"
|
||||
#import "NSObject+SBJSON.h"
|
||||
#import "NBNotifier.h"
|
||||
|
@ -1826,7 +1825,8 @@ heightForHeaderInSection:(NSInteger)section {
|
|||
if (![appDelegate.dictFeeds objectForKey:feed_id]) continue;
|
||||
NSString *favicon = [results objectForKey:feed_id];
|
||||
if ((NSNull *)favicon != [NSNull null] && [favicon length] > 0) {
|
||||
NSData *imageData = [NSData dataWithBase64EncodedString:favicon];
|
||||
NSData *imageData = [[NSData alloc] initWithBase64EncodedString:favicon options:NSDataBase64DecodingIgnoreUnknownCharacters];
|
||||
// NSData *imageData = [NSData dataWithBase64EncodedString:favicon];
|
||||
UIImage *faviconImage = [UIImage imageWithData:imageData];
|
||||
[appDelegate saveFavicon:faviconImage feedId:feed_id];
|
||||
}
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
#import "UserProfileViewController.h"
|
||||
#import "ShareViewController.h"
|
||||
#import "StoryPageControl.h"
|
||||
#import "Base64.h"
|
||||
#import "Utilities.h"
|
||||
#import "NSString+HTML.h"
|
||||
#import "NBContainerViewController.h"
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
#import "FontSettingsViewController.h"
|
||||
#import "UserProfileViewController.h"
|
||||
#import "ShareViewController.h"
|
||||
#import "Base64.h"
|
||||
#import "Utilities.h"
|
||||
#import "NSString+HTML.h"
|
||||
#import "NBContainerViewController.h"
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
#import "NBContainerViewController.h"
|
||||
#import "StringHelper.h"
|
||||
#import "Utilities.h"
|
||||
#import "Base64.h"
|
||||
#import "AFNetworking.h"
|
||||
#import "StoriesCollection.h"
|
||||
|
||||
|
@ -422,7 +421,7 @@
|
|||
UIImage *favicon = [appDelegate getFavicon:feedId];
|
||||
NSData *faviconData = UIImagePNGRepresentation(favicon);
|
||||
NSString *feedImageUrl = [NSString stringWithFormat:@"data:image/png;charset=utf-8;base64,%@",
|
||||
[faviconData base64Encoding]];
|
||||
[faviconData base64EncodedDataWithOptions:NSDataBase64Encoding64CharacterLineLength]];
|
||||
NSString *publisherTitle = [NSString stringWithFormat:@"<img class=\"feed_favicon\" src=\"%@\"> %@",
|
||||
feedImageUrl, feedTitle];
|
||||
NSString *storyPublisher = [NSString stringWithFormat:@"<div class=\"NB-trainer-section-inner\">"
|
||||
|
|
|
@ -146,7 +146,6 @@
|
|||
43A4BAE915C866FA00F3B8D4 /* popoverBgSimple.png in Resources */ = {isa = PBXBuildFile; fileRef = 43A4BADA15C866FA00F3B8D4 /* popoverBgSimple.png */; };
|
||||
43A4BAEB15C893E300F3B8D4 /* FriendsListViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 43A4BAEA15C893E300F3B8D4 /* FriendsListViewController.xib */; };
|
||||
43A4C3D715B00966008787B5 /* ABTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 43A4C3BA15B00966008787B5 /* ABTableViewCell.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
|
||||
43A4C3D815B00966008787B5 /* Base64.m in Sources */ = {isa = PBXBuildFile; fileRef = 43A4C3BC15B00966008787B5 /* Base64.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
|
||||
43A4C3DA15B00966008787B5 /* GTMNString+HTML.m in Sources */ = {isa = PBXBuildFile; fileRef = 43A4C3C015B00966008787B5 /* GTMNString+HTML.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
|
||||
43A4C3DC15B00966008787B5 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 43A4C3C215B00966008787B5 /* main.m */; };
|
||||
43A4C3DD15B00966008787B5 /* MBProgressHUD.m in Sources */ = {isa = PBXBuildFile; fileRef = 43A4C3C415B00966008787B5 /* MBProgressHUD.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
|
||||
|
@ -762,8 +761,6 @@
|
|||
43A4BAEA15C893E300F3B8D4 /* FriendsListViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = FriendsListViewController.xib; sourceTree = "<group>"; };
|
||||
43A4C3B915B00966008787B5 /* ABTableViewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ABTableViewCell.h; path = "Other Sources/ABTableViewCell.h"; sourceTree = "<group>"; };
|
||||
43A4C3BA15B00966008787B5 /* ABTableViewCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = ABTableViewCell.m; path = "Other Sources/ABTableViewCell.m"; sourceTree = "<group>"; };
|
||||
43A4C3BB15B00966008787B5 /* Base64.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Base64.h; path = "Other Sources/Base64.h"; sourceTree = "<group>"; };
|
||||
43A4C3BC15B00966008787B5 /* Base64.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = Base64.m; path = "Other Sources/Base64.m"; sourceTree = "<group>"; };
|
||||
43A4C3BE15B00966008787B5 /* GTMDefines.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = GTMDefines.h; path = "Other Sources/GTMDefines.h"; sourceTree = "<group>"; };
|
||||
43A4C3BF15B00966008787B5 /* GTMNString+HTML.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "GTMNString+HTML.h"; path = "Other Sources/GTMNString+HTML.h"; sourceTree = "<group>"; };
|
||||
43A4C3C015B00966008787B5 /* GTMNString+HTML.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "GTMNString+HTML.m"; path = "Other Sources/GTMNString+HTML.m"; sourceTree = "<group>"; };
|
||||
|
@ -1527,8 +1524,6 @@
|
|||
43A4C3E615B0099B008787B5 /* NewsBlur_Prefix.pch */,
|
||||
43A4C3B915B00966008787B5 /* ABTableViewCell.h */,
|
||||
43A4C3BA15B00966008787B5 /* ABTableViewCell.m */,
|
||||
43A4C3BB15B00966008787B5 /* Base64.h */,
|
||||
43A4C3BC15B00966008787B5 /* Base64.m */,
|
||||
43A4C3BE15B00966008787B5 /* GTMDefines.h */,
|
||||
43A4C3BF15B00966008787B5 /* GTMNString+HTML.h */,
|
||||
43A4C3C015B00966008787B5 /* GTMNString+HTML.m */,
|
||||
|
@ -3142,7 +3137,6 @@
|
|||
437F976F15AE21290007136B /* ActivityModule.m in Sources */,
|
||||
437F977215AE70E30007136B /* InteractionsModule.m in Sources */,
|
||||
43A4C3D715B00966008787B5 /* ABTableViewCell.m in Sources */,
|
||||
43A4C3D815B00966008787B5 /* Base64.m in Sources */,
|
||||
43A4C3DA15B00966008787B5 /* GTMNString+HTML.m in Sources */,
|
||||
43A4C3DC15B00966008787B5 /* main.m in Sources */,
|
||||
43A4C3DD15B00966008787B5 /* MBProgressHUD.m in Sources */,
|
||||
|
|
|
@ -1,15 +0,0 @@
|
|||
//
|
||||
// Base64.h
|
||||
// NewsBlur
|
||||
//
|
||||
// Created by Samuel Clay on 8/3/11.
|
||||
// Copyright 2011 NewsBlur. All rights reserved.
|
||||
//
|
||||
|
||||
|
||||
|
||||
@interface NSData (MBBase64)
|
||||
|
||||
+ (id)dataWithBase64EncodedString:(NSString *)string; // Padding '=' characters are optional. Whitespace is ignored.
|
||||
- (NSString *)base64Encoding;
|
||||
@end
|
|
@ -1,111 +0,0 @@
|
|||
#include "Base64.h"
|
||||
|
||||
static const char encodingTable[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
||||
|
||||
|
||||
@implementation NSData (MBBase64)
|
||||
|
||||
+ (id)dataWithBase64EncodedString:(NSString *)string;
|
||||
{
|
||||
if (string == nil)
|
||||
[NSException raise:NSInvalidArgumentException format:@""];
|
||||
if ([string length] == 0)
|
||||
return [NSData data];
|
||||
|
||||
static char *decodingTable = NULL;
|
||||
if (decodingTable == NULL)
|
||||
{
|
||||
decodingTable = malloc(256);
|
||||
if (decodingTable == NULL)
|
||||
return nil;
|
||||
memset(decodingTable, CHAR_MAX, 256);
|
||||
NSUInteger i;
|
||||
for (i = 0; i < 64; i++)
|
||||
decodingTable[(short)encodingTable[i]] = i;
|
||||
}
|
||||
|
||||
const char *characters = [string cStringUsingEncoding:NSASCIIStringEncoding];
|
||||
if (characters == NULL) // Not an ASCII string!
|
||||
return nil;
|
||||
char *bytes = malloc((([string length] + 3) / 4) * 3);
|
||||
if (bytes == NULL)
|
||||
return nil;
|
||||
NSUInteger length = 0;
|
||||
|
||||
NSUInteger i = 0;
|
||||
while (YES)
|
||||
{
|
||||
char buffer[4];
|
||||
short bufferLength;
|
||||
for (bufferLength = 0; bufferLength < 4; i++)
|
||||
{
|
||||
if (characters[i] == '\0')
|
||||
break;
|
||||
if (isspace(characters[i]) || characters[i] == '=')
|
||||
continue;
|
||||
buffer[bufferLength] = decodingTable[(short)characters[i]];
|
||||
if (buffer[bufferLength++] == CHAR_MAX) // Illegal character!
|
||||
{
|
||||
free(bytes);
|
||||
return nil;
|
||||
}
|
||||
}
|
||||
|
||||
if (bufferLength == 0)
|
||||
break;
|
||||
if (bufferLength == 1) // At least two characters are needed to produce one byte!
|
||||
{
|
||||
free(bytes);
|
||||
return nil;
|
||||
}
|
||||
|
||||
// Decode the characters in the buffer to bytes.
|
||||
bytes[length++] = (buffer[0] << 2) | (buffer[1] >> 4);
|
||||
if (bufferLength > 2)
|
||||
bytes[length++] = (buffer[1] << 4) | (buffer[2] >> 2);
|
||||
if (bufferLength > 3)
|
||||
bytes[length++] = (buffer[2] << 6) | buffer[3];
|
||||
}
|
||||
|
||||
char *temp = realloc(bytes, length);
|
||||
|
||||
if (temp) {
|
||||
return [NSData dataWithBytesNoCopy:bytes length:length];
|
||||
} else {
|
||||
return nil;
|
||||
}
|
||||
}
|
||||
|
||||
- (NSString *)base64Encoding;
|
||||
{
|
||||
if ([self length] == 0)
|
||||
return @"";
|
||||
|
||||
char *characters = malloc((([self length] + 2) / 3) * 4);
|
||||
if (characters == NULL)
|
||||
return nil;
|
||||
NSUInteger length = 0;
|
||||
|
||||
NSUInteger i = 0;
|
||||
while (i < [self length])
|
||||
{
|
||||
char buffer[3] = {0,0,0};
|
||||
short bufferLength = 0;
|
||||
while (bufferLength < 3 && i < [self length])
|
||||
buffer[bufferLength++] = ((char *)[self bytes])[i++];
|
||||
|
||||
// Encode the bytes in the buffer to four characters, including padding "=" characters if necessary.
|
||||
characters[length++] = encodingTable[(buffer[0] & 0xFC) >> 2];
|
||||
characters[length++] = encodingTable[((buffer[0] & 0x03) << 4) | ((buffer[1] & 0xF0) >> 4)];
|
||||
if (bufferLength > 1)
|
||||
characters[length++] = encodingTable[((buffer[1] & 0x0F) << 2) | ((buffer[2] & 0xC0) >> 6)];
|
||||
else characters[length++] = '=';
|
||||
if (bufferLength > 2)
|
||||
characters[length++] = encodingTable[buffer[2] & 0x3F];
|
||||
else characters[length++] = '=';
|
||||
}
|
||||
|
||||
return [[[NSString alloc] initWithBytesNoCopy:characters length:length encoding:NSASCIIStringEncoding freeWhenDone:YES] autorelease];
|
||||
}
|
||||
|
||||
@end
|
Loading…
Add table
Reference in a new issue