Browse Source
fix(StoryViewerFragment): crash when parsing unexpected Instagram id
renovate/org.robolectric-robolectric-4.x
Pablo Rodríguez Caballero
4 years ago
No known key found for this signature in database
GPG Key ID: 2788EF5E4218A68E
1 changed files with
19 additions and
1 deletions
-
app/src/main/java/awais/instagrabber/fragments/StoryViewerFragment.java
|
|
@ -65,6 +65,8 @@ import java.util.ArrayList; |
|
|
|
import java.util.Collections; |
|
|
|
import java.util.Date; |
|
|
|
import java.util.List; |
|
|
|
import java.util.regex.Matcher; |
|
|
|
import java.util.regex.Pattern; |
|
|
|
|
|
|
|
import awais.instagrabber.BuildConfig; |
|
|
|
import awais.instagrabber.R; |
|
|
@ -735,7 +737,7 @@ public class StoryViewerFragment extends Fragment { |
|
|
|
return; |
|
|
|
} |
|
|
|
final HighlightModel model = models.get(currentFeedStoryIndex); |
|
|
|
currentStoryMediaId = model.getId(); |
|
|
|
currentStoryMediaId = parseStoryMediaId(model.getId()); |
|
|
|
currentStoryUsername = model.getTitle(); |
|
|
|
fetchOptions = StoryViewerOptions.forUser(Long.parseLong(currentStoryMediaId), currentStoryUsername); |
|
|
|
break; |
|
|
@ -1146,4 +1148,20 @@ public class StoryViewerFragment extends Fragment { |
|
|
|
resetView(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* Parses the Story's media ID. For user stories this is a number, but for archive stories |
|
|
|
* this is "archiveDay:" plus a number. |
|
|
|
*/ |
|
|
|
private static String parseStoryMediaId(String rawId) { |
|
|
|
final String regex = "(?:archiveDay:)?(.+)"; |
|
|
|
final Pattern pattern = Pattern.compile(regex); |
|
|
|
final Matcher matcher = pattern.matcher(rawId); |
|
|
|
|
|
|
|
if (matcher.matches() && matcher.groupCount() >= 1) { |
|
|
|
return matcher.group(1); |
|
|
|
} |
|
|
|
|
|
|
|
return rawId; |
|
|
|
} |
|
|
|
} |