Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixes for user profile parsing, very hacky.

  • Loading branch information...
commit bb966d9928d3f6c38aab0982b63235741bb190d7 1 parent c8b3415
@newsyc newsyc authored
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"];
Please sign in to comment.
Something went wrong with that request. Please try again.