@@ -19,11 +19,12 @@ import (
1919
2020// Login represents a single pass login.
2121type Login struct {
22- Username string `json:"u"`
23- Password string `json:"p"`
24- OTP string `json:"digits"`
25- OTPLabel string `json:"label"`
26- URL string `json:"url"`
22+ Username string `json:"u"`
23+ Password string `json:"p"`
24+ OTP string `json:"digits"`
25+ OTPLabel string `json:"label"`
26+ URL string `json:"url"`
27+ AutoSubmit * bool `json:"autoSubmit,omitempty"`
2728}
2829
2930var endianness = binary .LittleEndian
@@ -37,7 +38,7 @@ var endianness = binary.LittleEndian
3738// Config defines the root config structure sent from the browser extension
3839type Config struct {
3940 // Manual searches use FuzzySearch if true, GlobSearch otherwise
40- UseFuzzy bool `json:"use_fuzzy_search"`
41+ UseFuzzy bool `json:"use_fuzzy_search"`
4142 CustomStores []pass.StoreDefinition `json:"customStores"`
4243}
4344
@@ -231,19 +232,31 @@ func parseLogin(r io.Reader) (*Login, error) {
231232 // Keep reading file for string in "login:", "username:" or "user:" format (case insensitive).
232233 userPattern := regexp .MustCompile ("(?i)^(login|username|user):" )
233234 urlPattern := regexp .MustCompile ("(?i)^(url|link|website|web|site):" )
235+ autoSubmitPattern := regexp .MustCompile ("(?i)^autosubmit:" )
234236 for scanner .Scan () {
235237 line := scanner .Text ()
236- parseTotp (line , login )
237- replaced := userPattern .ReplaceAllString (line , "" )
238- if len (replaced ) != len (line ) {
239- login .Username = strings .TrimSpace (replaced )
238+ if login .OTP == "" {
239+ parseTotp (line , login )
240+ }
241+ if login .Username == "" {
242+ replaced := userPattern .ReplaceAllString (line , "" )
243+ if len (replaced ) != len (line ) {
244+ login .Username = strings .TrimSpace (replaced )
245+ }
240246 }
241247 if login .URL == "" {
242- replaced = urlPattern .ReplaceAllString (line , "" )
248+ replaced : = urlPattern .ReplaceAllString (line , "" )
243249 if len (replaced ) != len (line ) {
244250 login .URL = strings .TrimSpace (replaced )
245251 }
246252 }
253+ if login .AutoSubmit == nil {
254+ replaced := autoSubmitPattern .ReplaceAllString (line , "" )
255+ if len (replaced ) != len (line ) {
256+ value := strings .ToLower (strings .TrimSpace (replaced )) == "true"
257+ login .AutoSubmit = & value
258+ }
259+ }
247260 }
248261
249262 // if an unlabelled OTP is present, label it with the username
0 commit comments