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

AdHash Bid Adapter: changes to support preroll videos #9870

Merged
merged 33 commits into from
May 23, 2023
Merged
Changes from 1 commit
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
e7d3b8a
AdHash Bidder Adapter: minor changes
wyand-sp Jan 7, 2022
814f3a8
Implemented brand safety
wyand-sp Jan 18, 2022
d5e34de
Fix for GDPR consent
wyand-sp Mar 10, 2022
4eb1553
Merge branch 'prebid:master' into master
wyand-sp Mar 10, 2022
bdc4fad
Ad fraud prevention formula changed
wyand-sp Mar 16, 2022
35f24dc
AdHash brand safety additions
wyand-sp Apr 14, 2022
e681fbd
AdHash brand safety updates
wyand-sp Jun 28, 2022
c837c36
Merge branch 'master' of https://github.com/AdHashProtocol/Prebid.js
wyand-sp Aug 5, 2022
a6c5faf
AdHash Analytics adapter
wyand-sp Aug 5, 2022
fc5809d
Merge branch 'prebid:master' into master
wyand-sp Aug 10, 2022
3fa0e52
Support for recent ads
wyand-sp Aug 17, 2022
66fddd1
Fix for timestamp
wyand-sp Aug 18, 2022
0c7953c
PUB-222
Sep 15, 2022
66d14ba
Unit tests for the analytics adapter
Sep 19, 2022
1c2470a
Removed export causing errors
Sep 19, 2022
6e4148b
Added globalScript parameter
wyand-sp Sep 26, 2022
ae443ae
Merge branch 'prebid:master' into master
wyand-sp Oct 4, 2022
441240d
PUB-227
vsaraminev Oct 4, 2022
a589f12
Merge branch 'prebid:master' into master
wyand-sp Oct 12, 2022
8dacbc9
GEN-964
M1TKO Oct 28, 2022
9cd75bf
GEN-1025
Nov 16, 2022
dbd9f3d
Removing the analytics adaptor
wyand-sp Nov 28, 2022
65a0d26
Fix for regexp match
wyand-sp Nov 28, 2022
e27cbe4
Version change
wyand-sp Nov 28, 2022
d68efac
MINOR
wyand-sp Dec 7, 2022
e8ab5c2
Merge branch 'prebid:master' into master
wyand-sp Feb 7, 2023
78dea30
GEN-1153
Apr 27, 2023
340e473
MINOR
wyand-sp Apr 28, 2023
cc6994b
Merge branch 'prebid:master' into master
wyand-sp Apr 28, 2023
9ee05e2
Removing globalScript flag
wyand-sp May 9, 2023
2d9d9f2
Merge branch 'prebid:master' into master
wyand-sp May 18, 2023
17cce26
Merge branch 'prebid:master' into master
wyand-sp May 18, 2023
c5942e5
Merge branch 'prebid:master' into master
wyand-sp May 19, 2023
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
PUB-227
Support for non-latin and non-cyrillic symbols
  • Loading branch information
vsaraminev committed Oct 4, 2022
commit 441240df1251967bc7bc173b1f66657041499fda
47 changes: 15 additions & 32 deletions modules/adhashBidAdapter.js
Original file line number Diff line number Diff line change
@@ -63,46 +63,29 @@ function brandSafety(badWords, maxScore) {
try {
let score = 0;
const content = window.top.document.body.innerText.toLowerCase();
const words = content.trim().split(/\s+/).length;
// Cyrillic unicode block range - 0400-04FF
const cyrillicWords = content.match(/[\u0400-\u04FF]+/gi);
const contentWords = content.trim().split(/\s+/).length;
// \p{L} matches a single unicode code point in the category 'letter'. Matches any kind of letter from any language.
const words = content.match(/[\p{L}-]+/ug);
for (const [word, rule, points] of badWords) {
const decodedWord = rot13(word);
if (
(rule === 'full' && new RegExp('\\b' + decodedWord + '\\b', 'i').test(content)) ||
(rule === 'full' && cyrillicWords && cyrillicWords.includes(decodedWord))
) {
const occurances = cyrillicWords && cyrillicWords.includes(decodedWord)
? cyrillicWords.filter(word => word === decodedWord).length
: content.match(new RegExp('\\b' + decodedWord + '\\b', 'g')).length;
const decodedWord = rot13(word.toLowerCase());
if (rule === 'full' && words && words.includes(decodedWord)) {
const occurances = words.filter(word => word === decodedWord).length;
score += scoreCalculator(points, occurances);
} else if (rule === 'partial' && content.indexOf(rot13(word.toLowerCase())) > -1) {
const occurances = content.match(new RegExp(decodedWord, 'g')).length;
} else if (rule === 'partial' && words && words.some(word => word.indexOf(decodedWord) > -1)) {
const occurances = words.filter(word => word.indexOf(decodedWord) > -1).length;
score += scoreCalculator(points, occurances);
} else if (
(rule === 'starts' && new RegExp('\\b' + decodedWord, 'i').test(content)) ||
(rule === 'starts' && cyrillicWords && cyrillicWords.some(word => word.startsWith(decodedWord)))
) {
const occurances =
cyrillicWords && cyrillicWords.some(word => word.startsWith(decodedWord))
? cyrillicWords.find(word => word.startsWith(decodedWord)).length
: content.match(new RegExp('\\b' + decodedWord, 'g')).length;
} else if (rule === 'starts' && words && words.some(word => word.startsWith(decodedWord))) {
const occurances = words.find(word => word.startsWith(decodedWord)).length;
score += scoreCalculator(points, occurances);
} else if (
(rule === 'ends' && new RegExp(decodedWord + '\\b', 'i').test(content)) ||
(rule === 'ends' && cyrillicWords && cyrillicWords.some(word => word.endsWith(decodedWord)))
) {
const occurances =
cyrillicWords && cyrillicWords.some(word => word.endsWith(decodedWord))
? cyrillicWords.find(word => word.endsWith(decodedWord)).length
: content.match(new RegExp(decodedWord + '\\b', 'g')).length;
} else if (rule === 'ends' && words && words.some(word => word.endsWith(decodedWord))) {
const occurances = words.find(word => word.endsWith(decodedWord)).length;
score += scoreCalculator(points, occurances);
} else if (rule === 'regexp' && new RegExp(decodedWord, 'i').test(content)) {
const occurances = content.match(new RegExp(decodedWord, 'g')).length;
} else if (rule === 'regexp' && words && words.includes(decodedWord)) {
const occurances = words.filter(word => word === decodedWord).length;
score += scoreCalculator(points, occurances);
}
}
return score < maxScore * words / 1000;
return score < maxScore * contentWords / 1000;
} catch (e) {
return true;
}