<commit_before>#import "MWMAlertViewController.h"
#import "MWMAuthorizationCommon.h"
#import "MWMAuthorizationWebViewLoginViewController.h"
#import "MWMCircularProgress.h"
#import "Statistics.h"
#import "SettingsAndMoreVC.h"

#include "base/logging.hpp"
#include "editor/osm_auth.hpp"

using namespace osm;

namespace
{
NSString * const kVerifierKey = @"oauth_verifier";

BOOL checkURLHasVerifierKey(NSString * urlString)
{
  return [urlString containsString:kVerifierKey];
}

BOOL checkURLNeedsReload(NSString * urlString)
{
  return [urlString hasSuffix:@"/"] || [urlString containsString:@"/welcome"];
}

NSString * getVerifier(NSString * urlString)
{
  NSString * query = [urlString componentsSeparatedByString:@"?"].lastObject;
  NSArray<NSString *> * queryComponents = [query componentsSeparatedByString:@"&"];
  NSString * verifierValue = nil;
  for (NSString * keyValuePair in queryComponents)
  {
    NSArray * pairComponents = [keyValuePair componentsSeparatedByString:@"="];
    NSString * key = [pairComponents.firstObject stringByRemovingPercentEncoding];
    if (![key isEqualToString:kVerifierKey])
      continue;<commit_msg>[ios] Fix OAuth on iOS7<commit_after>#import "Common.h"
#import "MWMAlertViewController.h"
#import "MWMAuthorizationCommon.h"
#import "MWMAuthorizationWebViewLoginViewController.h"
#import "MWMCircularProgress.h"
#import "Statistics.h"
#import "SettingsAndMoreVC.h"

#include "base/logging.hpp"
#include "editor/osm_auth.hpp"

using namespace osm;

namespace
{
NSString * const kVerifierKey = @"oauth_verifier";

BOOL checkURLHasVerifierKey(NSString * urlString)
{
  return isIOS7 ? [urlString rangeOfString:kVerifierKey].location != NSNotFound :
                  [urlString containsString:kVerifierKey];
}

BOOL checkURLNeedsReload(NSString * urlString)
{
  BOOL const hasSlashSuffix = [urlString hasSuffix:@"/"];
  if (!isIOS7)
    return hasSlashSuffix || [urlString containsString:@"/welcome"];
  return hasSlashSuffix || ([urlString rangeOfString:@"/welcome"].location != NSNotFound);

}

NSString * getVerifier(NSString * urlString)
{
  NSString * query = [urlString componentsSeparatedByString:@"?"].lastObject;
  NSArray<NSString *> * queryComponents = [query componentsSeparatedByString:@"&"];
  NSString * verifierValue = nil;
  for (NSString * keyValuePair in queryComponents)
  {
    NSArray * pairComponents = [keyValuePair componentsSeparatedByString:@"="];
    NSString * key = [pairComponents.firstObject stringByRemovingPercentEncoding];
    if (![key isEqualToString:kVerifierKey])
      continue;
{'fraction_non_alphanumeric': 0.11888932342588972, 'fraction_numerical': 0.0011732499022291747, 'mean_word_length': 6.287749287749287, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2019465', 'n_tokens_mistral': 850, 'n_tokens_neox': 778, 'n_words': 158}