Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add yandexbrowser #9

Merged
merged 3 commits into from
Apr 16, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
implement: detect Yandex Browser
hhatto committed Apr 14, 2018
commit 19de2e4530ac710f2f833d15b8d32abe3fb68503
26 changes: 26 additions & 0 deletions src/parser.rs
Original file line number Diff line number Diff line change
@@ -50,6 +50,7 @@ lazy_static! {
static ref RX_PEAR: Regex = Regex::new(r"(?:PEAR HTTP_Request|HTTP_Request)(?: class|2)").unwrap();
static ref RX_MAYBE_CRAWLER_OTHER: Regex = Regex::new(r"(?:Rome Client |UnwindFetchor/|ia_archiver |Summify |PostRank/)").unwrap();
static ref RE_SLEIPNIR_VERSION: Regex = Regex::new(r"Sleipnir/([.0-9]+)").unwrap();
static ref RX_YABROWSER_VERSION: Regex = Regex::new(r"YaBrowser/(\d+\.\d+\.\d+\.\d+)").unwrap();
}

#[derive(Debug, Default)]
@@ -225,6 +226,10 @@ impl Parser {
return true;
}

if self.challenge_yandexbrowser(agent, result) {
return true;
}

if self.challenge_safari_chrome(agent, result) {
return true;
}
@@ -535,6 +540,27 @@ impl Parser {
true
}

fn challenge_yandexbrowser<'a>(&self, agent: &'a str, result: &mut WootheeResult<'a>) -> bool {
if !agent.contains("YaBrowser/") {
return false;
}

match RX_YABROWSER_VERSION.captures(agent) {
Some(caps) => {
result.version = caps.get(1).unwrap().as_str();
}
None => {
return false;
}
}

if !self.populate_dataset(result, "YaBrowser") {
return false;
}

true
}

fn challenge_safari_chrome<'a>(&self, agent: &'a str, result: &mut WootheeResult<'a>) -> bool {
if agent.contains("Chrome") && agent.contains("wv") {
return false;