Skip to content

Commit

Permalink
Escape symbols for city. Some cities have '
Browse files Browse the repository at this point in the history
  • Loading branch information
JunesiPhone committed Mar 26, 2019
1 parent 33cbea9 commit 18442de
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
10 changes: 6 additions & 4 deletions Tweak/Weather/XIWeather.m
Original file line number Diff line number Diff line change
Expand Up @@ -195,9 +195,9 @@ - (NSString*)_variablesToJSString {
@"hourIndex": [NSNumber numberWithInt:hourForecast.hourIndex]
}];
}

NSDictionary *weatherInfo = @{
@"city": self.currentCity.name != nil ? self.currentCity.name : @"Local Weather",
@"city": [self _escapeString:self.currentCity.name] != nil ? [self _escapeString:self.currentCity.name] : @"Local Weather",
@"address": self.reverseGeocodedAddress ? self.reverseGeocodedAddress : @{},
@"temperature": [NSNumber numberWithInt:temp],
@"low": dailyForecasts.count > 0 ? [dailyForecasts[0] objectForKey:@"low"] : @0,
Expand Down Expand Up @@ -228,7 +228,7 @@ - (NSString*)_variablesToJSString {
@"precipitation24hr": [NSNumber numberWithFloat:self.currentCity.precipitationPast24Hours],
@"heatIndex": [NSNumber numberWithInt:(int)roundf(self.currentCity.heatIndex)],
@"moonPhase": [NSNumber numberWithInt:(int)roundf(self.currentCity.moonPhase)],
@"cityState": self.currentCity.cityAndState != nil ? self.currentCity.cityAndState : @""
@"cityState": [self _escapeString:self.currentCity.cityAndState] != nil ? [self _escapeString:self.currentCity.cityAndState] : @""
};

NSString * jsonObj = [[NSString alloc] initWithData:[NSJSONSerialization dataWithJSONObject:weatherInfo
Expand All @@ -243,7 +243,9 @@ - (NSString*)_escapeString:(NSString*)input {
if (!input)
return @"";

input = [input stringByReplacingOccurrencesOfString:@"'" withString:@"\\'"];
input = [input stringByReplacingOccurrencesOfString:@"'" withString:@"'"];
input = [input stringByReplacingOccurrencesOfString:@"&" withString:@"&"];
input = [input stringByReplacingOccurrencesOfString:@"+" withString:@"+"];
input = [input stringByReplacingOccurrencesOfString: @"\"" withString:@"\\\""];
input = [input stringByReplacingOccurrencesOfString: @"/" withString:@"\\/"];

Expand Down
2 changes: 1 addition & 1 deletion control
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: com.junesiphone.xeninfo
Name: XenInfo
Depends: mobilesubstrate, firmware (>= 9.0)
Version: 2.2.1
Version: 2.2.2
Conflicts: org.bigboss.datameter, cydia.kiiimo.org.datameter, com.repo.xarold.com.datameter, re.rejail.datameter, org.coolstar.ventana-modern, com.repo.xarold.com.ventana, cydia.kiiimo.org.ventana
Architecture: iphoneos-arm
Description: Music, Weather, and battery info for XenHTML
Expand Down

0 comments on commit 18442de

Please sign in to comment.