Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 905fad52 authored by Torne (Richard Coles)'s avatar Torne (Richard Coles) Committed by android-build-merger
Browse files

Merge "Only match addresses without zip codes if at the end." into pi-dev am: 2946fba3

am: 935210c8

Change-Id: I4ebf09353235d989b90260df56827ddcde862c43
parents 3f37fcaf 935210c8
Loading
Loading
Loading
Loading
+14 −13
Original line number Original line Diff line number Diff line
@@ -429,23 +429,24 @@ class FindAddress {


                    // At this point we've matched a state; try to match a zip code after it.
                    // At this point we've matched a state; try to match a zip code after it.
                    Matcher zipMatcher = sWordRe.matcher(content);
                    Matcher zipMatcher = sWordRe.matcher(content);
                    if (zipMatcher.find(stateMatch.end())
                    if (zipMatcher.find(stateMatch.end())) {
                            && isValidZipCode(zipMatcher.group(0), stateMatch)) {
                        if (isValidZipCode(zipMatcher.group(0), stateMatch)) {
                            return zipMatcher.end();
                            return zipMatcher.end();
                        }
                        }
                    } else {
                        // The content ends with a state but no zip
                        // The content ends with a state but no zip
                        // code. This is a legal match according to the
                        // code. This is a legal match according to the
                    // documentation. N.B. This differs from the
                        // documentation. N.B. This is equivalent to the
                        // original c++ implementation, which only allowed
                        // original c++ implementation, which only allowed
                        // the zip code to be optional at the end of the
                        // the zip code to be optional at the end of the
                    // string, which presumably is a bug.  Now we
                        // string, which presumably is a bug.  We tried
                    // prefer to find a match with a zip code, but
                        // relaxing this to work in other places but it
                    // remember non-zip matches and return them if
                        // caused too many false positives.
                    // necessary.
                        nonZipMatch = stateMatch.end();
                        nonZipMatch = stateMatch.end();
                    }
                    }
                }
                }
            }
            }
        }


        if (nonZipMatch > 0) return nonZipMatch;
        if (nonZipMatch > 0) return nonZipMatch;