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

[FormAnalyzer] Don't flip scores on buttons with specific text #725

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
14 changes: 12 additions & 2 deletions dist/autofill-debug.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 12 additions & 2 deletions dist/autofill.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 12 additions & 2 deletions src/Form/FormAnalyzer.js
Original file line number Diff line number Diff line change
Expand Up @@ -279,8 +279,7 @@ class FormAnalyzer {
} else {
// Here we don't think this is a submit, so if there is another submit in the form, flip the score
const thereIsASubmitButton = Boolean(this.form.querySelector('input[type=submit], button[type=submit]'));
const isSocialButton = /facebook|twitter|google|apple/i.test(string);
shouldFlip = thereIsASubmitButton && !isSocialButton;
shouldFlip = thereIsASubmitButton && this.shouldFlipScoreForButtonText(string);
}
const strength = likelyASubmit ? 20 : 4;
this.updateSignal({ string, strength, signalType: `button: ${string}`, shouldFlip });
Expand Down Expand Up @@ -383,6 +382,17 @@ class FormAnalyzer {
this._isCCForm = Boolean(textMatches && deDupedMatches.size > 1);
return this._isCCForm;
}

/**
* @param {string} text
* @returns {boolean}
*/
shouldFlipScoreForButtonText(text) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wanted to re-use this also for external link part, but that's a little bit different in terms of score strength. keeping it

const isForgotPassword = safeRegexTest(this.matching.getDDGMatcherRegex('resetPasswordLink'), text);
const isStaySignedIn = /stay.?signed.?in$/i.test(text);
const isSocialButton = /facebook|twitter|google|apple/i.test(text);
return !isForgotPassword && !isStaySignedIn && !isSocialButton;
}
}

export default FormAnalyzer;
14 changes: 12 additions & 2 deletions swift-package/Resources/assets/autofill-debug.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 12 additions & 2 deletions swift-package/Resources/assets/autofill.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

68 changes: 68 additions & 0 deletions test-forms/auth_wetransfer_com_login.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<div id="panel-login" role="tabpanel" tabindex="-1" aria-expanded="true" aria-labelledby="tab-login">
<div class="auth-lock-social-buttons-pane">
<div class="auth0-lock-social-buttons-container"><a
class="auth0-lock-social-button auth0-lock-social-big-button" data-provider="google-oauth2"
type="button" aria-label="Continue with Google" aria-describedby="google-button" tabindex="2"
role="button" aria-pressed="false">
<div class="auth0-lock-social-button-icon"></div>
<div class="auth0-lock-social-button-text" id="google-button">Continue with Google</div>
</a><a class="auth0-lock-social-button auth0-lock-social-big-button" data-provider="oauth2" type="button"
style="background-color: rgb(255, 255, 255);" aria-label="Continue with Slack"
aria-describedby="slack-button" tabindex="3" role="button" aria-pressed="false">
<div class="auth0-lock-social-button-icon"
style="background-image: url(&quot;data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4KPCEtLSBHZW5lcmF0b3I6IEFkb2JlIElsbHVzdHJhdG9yIDIzLjAuMSwgU1ZHIEV4cG9ydCBQbHVnLUluIC4gU1ZHIFZlcnNpb246IDYuMDAgQnVpbGQgMCkgIC0tPgo8c3ZnIHZlcnNpb249IjEuMSIgaWQ9IkxheWVyXzEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIHg9IjBweCIgeT0iMHB4IgoJIHZpZXdCb3g9IjAgMCAyNzAgMjcwIiBzdHlsZT0iZW5hYmxlLWJhY2tncm91bmQ6bmV3IDA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cuMSwwLDEyLjksNS44LDEyLjksMTIuOXMtNS44LDEyLjktMTIuOSwxMi45aC0xMi45VjExOC44eiIvPgoJCTxwYXRoIGNsYXNzPSJzdDIiIGQ9Ik0xNjQuMSwxMTguOGMwLDcuMS01LjgsMTIuOS0xMi45LDEyLjljLTcuMSwwLTEyLjktNS44LTEyLjktMTIuOVY4Ni41YzAtNy4xLDUuOC0xMi45LDEyLjktMTIuOQoJCQljNy4xLDAsMTIuOSw1LjgsMTIuOSwxMi45VjExOC44eiIvPgoJPC9nPgoJPGc+CgkJPHBhdGggY2xhc3M9InN0MyIgZD0iTTE1MS4yLDE3MC42YzcuMSwwLDEyLjksNS44LDEyLjksMTIuOWMwLDcuMS01LjgsMTIuOS0xMi45LDEyLjljLTcuMSwwLTEyLjktNS44LTEyLjktMTIuOXYtMTIuOUgxNTEuMnoiLz4KCQk8cGF0aCBjbGFzcz0ic3QzIiBkPSJNMTUxLjIsMTY0LjFjLTcuMSwwLTEyLjktNS44LTEyLjktMTIuOWMwLTcuMSw1LjgtMTIuOSwxMi45LTEyLjloMzIuM2M3LjEsMCwxMi45LDUuOCwxMi45LDEyLjkKCQkJYzAsNy4xLTUuOCwxMi45LTEyLjksMTIuOUgxNTEuMnoiLz4KCTwvZz4KPC9nPgo8L3N2Zz4K&quot;);">
</div>
<div class="auth0-lock-social-button-text" style="color: rgb(0, 0, 0);" id="slack-button">Continue with
Slack</div>
</a><a class="auth0-lock-social-button auth0-lock-social-big-button" data-provider="apple" type="button"
aria-label="Continue with Apple" aria-describedby="apple-button" tabindex="4" role="button"
aria-pressed="false">
<div class="auth0-lock-social-button-icon"></div>
<div class="auth0-lock-social-button-text" id="apple-button">Continue with Apple</div>
</a></div>
</div>
<div class="auth0-lock-pane-separator"></div>
<div>
<p><span>Or better yet...</span></p>
<div class="auth0-lock-input-block auth0-lock-input-email">
<div class="auth0-lock-input-wrap auth0-lock-input-wrap-with-icon"><svg aria-hidden="true" focusable="false"
width="14px" height="13px" viewBox="0 0 32 26" version="1.1" xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink" class="auth0-lock-icon auth0-lock-icon-box">
<g id="Page-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
<g id="32px" transform="translate(-2155.000000, -2317.000000)" fill="#373A39">
<g id="Group-856" transform="translate(1.000000, 1.000000)">
<path id="Fill-419"
d="M2184,2339 C2184,2339.55 2183.55,2340 2183,2340 L2157,2340 C2156.45,2340 2156,2339.55 2156,2339 L2156,2319 C2156,2318.45 2156.45,2318 2157,2318 L2183,2318 C2183.55,2318 2184,2318.45 2184,2319 L2184,2339 L2184,2339 Z M2184,2316 L2156,2316 C2154.89,2316 2154,2316.89 2154,2318 L2154,2340 C2154,2341.1 2154.89,2342 2156,2342 L2184,2342 C2185.1,2342 2186,2341.1 2186,2340 L2186,2318 C2186,2316.89 2185.1,2316 2184,2316 L2184,2316 Z M2176,2322 L2180,2322 L2180,2326 L2176,2326 L2176,2322 Z M2174,2328 L2182,2328 L2182,2320 L2174,2320 L2174,2328 Z M2158,2332 L2172,2332 L2172,2330 L2158,2330 L2158,2332 Z M2158,2336 L2172,2336 L2172,2334 L2158,2334 L2158,2336 Z">
</path>
</g>
</g>
</g>
</svg><input id="1-email" type="email" inputmode="email" name="email" class="auth0-lock-input"
placeholder="Email" autocomplete="off" autocapitalize="off" autocorrect="off" spellcheck="false"
aria-label="Email" aria-invalid="false" value="" tabindex="5" data-manual-scoring="username"
style="background-size: auto 24px !important; background-position: right center !important; background-repeat: no-repeat !important; background-origin: content-box !important; background-image: url(&quot;chrome-extension://bdb1ff7b-caf4-42a5-966c-751bc4d4a3dd/img/logo-small.svg&quot;) !important; transition: background !important;">
</div>
</div>
<div class="auth0-lock-input-block auth0-lock-input-show-password">
<div class="auth0-lock-input-block auth0-lock-input-password" style="display: none;">
<div class="auth0-lock-input-wrap auth0-lock-input-wrap-with-icon"><svg aria-hidden="true"
focusable="false" width="11px" height="14px" viewBox="0 0 13 16" version="1.1"
xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"
class="auth0-lock-icon auth0-lock-icon-box">
<g stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
<g transform="translate(-288.000000, -1508.000000)" fill="#888888">
<path
d="M299,1523.998 L290,1523.998 C288.896,1523.998 288,1523.102 288,1521.999 L288,1515.999 C288,1514.895 288.896,1513.998 290,1513.998 L290,1513.998 L290,1512.499 C290,1510.015 292.015,1507.999 294.5,1507.999 C296.985,1507.999 299,1510.015 299,1512.499 L299,1513.999 C300.104,1513.999 301,1514.895 301,1515.999 L301,1521.999 C301,1523.103 300.104,1523.998 299,1523.998 L299,1523.998 Z M298,1512.499 C298,1510.566 296.433,1508.999 294.5,1508.999 C292.567,1508.999 291,1510.566 291,1512.499 L291,1513.998 L298,1513.998 L298,1512.499 L298,1512.499 Z M300,1515.999 C300,1515.446 299.552,1514.998 299,1514.998 L290,1514.998 C289.447,1514.998 289,1515.446 289,1515.999 L289,1521.999 C289,1522.551 289.447,1522.998 290,1522.998 L299,1522.998 C299.552,1522.998 300,1522.551 300,1521.999 L300,1515.999 L300,1515.999 Z M294.5,1520.998 C294.224,1520.998 294,1520.774 294,1520.498 L294,1517.498 C294,1517.223 294.224,1516.999 294.5,1516.999 C294.776,1516.999 295,1517.223 295,1517.498 L295,1520.498 C295,1520.774 294.776,1520.998 294.5,1520.998 L294.5,1520.998 Z">
</path>
</g>
</g>
</svg><input type="password" id="1-password" name="password" class="auth0-lock-input"
autocomplete="off" autocapitalize="off" autocorrect="off" spellcheck="false"
aria-label="Password" aria-invalid="false" placeholder="Password" value="" tabindex="6"
data-manual-scoring="password.current"></div>
</div>
</div>
<p class="auth0-lock-alternative" style="display: none;"><a class="auth0-lock-alternative-link" href="#"
role="button" tabindex="7">Forgot password?</a></p>
</div>
</div>
46 changes: 46 additions & 0 deletions test-forms/freshdirect_com_login.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<form action="#" data-testid="sign-in-email-form" novalidate="">
<div class="MuiFormControl-root Input_default_input__bERwd SignInEmail_field__JT2rK fd-styles-13sljp9">
<div class="Input_input_wrapper__xNpZT"><label
class="MuiFormLabel-root MuiInputLabel-root MuiInputLabel-formControl MuiInputLabel-animated MuiInputLabel-shrink MuiInputLabel-outlined MuiFormLabel-colorPrimary MuiFormLabel-filled MuiInputLabel-root MuiInputLabel-formControl MuiInputLabel-animated MuiInputLabel-shrink MuiInputLabel-outlined fd-styles-5pg2in"
for="email">Email</label>
<div
class="MuiInputBase-root MuiOutlinedInput-root MuiInputBase-colorPrimary Mui-disabled MuiInputBase-formControl Input_default_input__bERwd fd-styles-10pfstc">
<input aria-invalid="false" autocomplete="email" id="email" name="email" type="email"
class="MuiInputBase-input MuiOutlinedInput-input Mui-disabled fd-styles-1x5jdmq"
value="[email protected]" disabled="" data-manual-scoring="username">
>
<fieldset aria-hidden="true" class="MuiOutlinedInput-notchedOutline fd-styles-igs3ac">
<legend class="fd-styles-14lo706"><span>Email</span></legend>
</fieldset>
</div>
</div>
</div>
<div
class="MuiFormControl-root Input_default_input__bERwd Input_password_input__wkG_8 SignInEmail_field__JT2rK fd-styles-13sljp9">
<div class="Input_input_wrapper__xNpZT"><label
class="MuiFormLabel-root MuiInputLabel-root MuiInputLabel-formControl MuiInputLabel-animated MuiInputLabel-shrink MuiInputLabel-outlined MuiFormLabel-colorPrimary Mui-focused MuiInputLabel-root MuiInputLabel-formControl MuiInputLabel-animated MuiInputLabel-shrink MuiInputLabel-outlined fd-styles-5pg2in"
for="password">Password</label>
<div
class="MuiInputBase-root MuiOutlinedInput-root MuiInputBase-colorPrimary Mui-focused MuiInputBase-formControl Input_default_input__bERwd fd-styles-10pfstc">
<input aria-invalid="false" id="password" name="password" type="password"
class="MuiInputBase-input MuiOutlinedInput-input fd-styles-1x5jdmq" value=""
data-manual-scoring="password.current" aria-autocomplete="list">
<fieldset aria-hidden="true" class="MuiOutlinedInput-notchedOutline fd-styles-igs3ac">
<legend class="fd-styles-14lo706"><span>Password</span></legend>
</fieldset>
</div>
</div>
</div>
<p class="MuiTypography-root MuiTypography-body SignInEmail_field__JT2rK fd-styles-vru47j"><button
class="MuiButtonBase-root MuiButton-root MuiButton-text MuiButton-textPrimary MuiButton-sizeMedium MuiButton-textSizeMedium MuiButton-root MuiButton-text MuiButton-textPrimary MuiButton-sizeMedium MuiButton-textSizeMedium Button_button__dve9_ Button_small__sV1Ch Button_underline_light__o7wxQ fd-styles-1jxmroj"
tabindex="0" type="button" data-qa="user_forgot_password">Forgot password?</button></p>
<div class="SignInEmail_submit_button_wrapper__5lp4S"><button
class="MuiButtonBase-root MuiButton-root MuiButton-text MuiButton-textPrimary MuiButton-sizeMedium MuiButton-textSizeMedium MuiButton-fullWidth MuiButton-root MuiButton-text MuiButton-textPrimary MuiButton-sizeMedium MuiButton-textSizeMedium MuiButton-fullWidth Button_button__dve9_ Button_large__bab3g Button_contained_light__uJjGM fd-styles-1dm0qdr"
tabindex="0" type="submit" data-qa="user_submit_auth" data-manual-submit>Continue</button></div>
<div class="SignInEmail_field__JT2rK">
<div class="Checkbox_wrapper__KONJK"><input id="persistent-login" type="checkbox" data-testid="input-test-id"
class="Checkbox_default_checkbox__x2yrh"><label for="persistent-login"
class="Checkbox_default_checkbox_label__ZfS17 Checkbox_center__aFoR0 Checkbox_label__tOaRX"><span
class="Checkbox_checkmark__d4fdZ" aria-hidden="true">✓</span>Stay signed in</label></div>
</div>
</form>
5 changes: 4 additions & 1 deletion test-forms/index.json
Original file line number Diff line number Diff line change
Expand Up @@ -548,5 +548,8 @@
{ "html": "accounts_oneplus_login.html"},
{ "html": "google_password_manager_search.html"},
{ "html": "paperlesspost_login.html"},
{ "html": "deltamath_reset_password.html"}
{ "html": "deltamath_reset_password.html"},
{ "html": "freshdirect_com_login.html"},
{ "html": "auth_wetransfer_com_login.html"},
{ "html": "revolut_business_login.html"}
]
Loading
Loading