Browse files

Fixes for user profile parsing, very hacky.

  • Loading branch information...
1 parent c8b3415 commit bb966d9928d3f6c38aab0982b63235741bb190d7 @newsyc newsyc committed Sep 5, 2011
Showing with 15 additions and 3 deletions.
  1. +15 −3 Classes/HNKit/HNAPIRequestParser.m
View
18 Classes/HNKit/HNAPIRequestParser.m
@@ -39,10 +39,22 @@ - (NSDictionary *)parseUserProfileWithString:(NSString *)string {
if ([value hasPrefix:mid]) value = [value substringFromIndex:[mid length]];
if ([key isEqual:@"about"]) {
- if ([value rangeOfString:@"</textarea>"].location != NSNotFound) {
- value = [value substringToIndex:[value rangeOfString:@"</textarea>"].location];
+ // XXX: hacky method to extract text from a textarea
+ if ([value rangeOfString:@"<textarea"].location != NSNotFound) {
+ NSString *tempValue = [value substringFromIndex:[value rangeOfString:@"<textarea"].location + [value rangeOfString:@"<textarea"].length];
+
+ if ([tempValue rangeOfString:@">"].location != NSNotFound) {
+ tempValue = [tempValue substringFromIndex:[tempValue rangeOfString:@">"].location + [tempValue rangeOfString:@">"].length];
+ if ([tempValue rangeOfString:@"\n"].location == 0) {
+ tempValue = [tempValue substringFromIndex:[tempValue rangeOfString:@"\n"].location + [tempValue rangeOfString:@"\n"].length];
+ }
+
+ if ([tempValue rangeOfString:@"</textarea>"].location != NSNotFound) {
+ value = [tempValue substringToIndex:[tempValue rangeOfString:@"</textarea>"].location];
+ }
+ }
}
-
+
[result setObject:value forKey:@"about"];
} else if ([key isEqual:@"karma"]) {
[result setObject:value forKey:@"karma"];

0 comments on commit bb966d9

Please sign in to comment.