Skip to content

Commit

Permalink
Merge branch 'master' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
Jerry authored and Jerry committed Nov 18, 2021
2 parents 0d21990 + ee72d51 commit 8af1606
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 3 deletions.
9 changes: 8 additions & 1 deletion assets/js/postcode-eu-autofill.js
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@
{
const postcode = postcodeRegex.exec(postcodeField.val())[0].replace(/\s/g, ''),
houseNumber = houseNumberRegex.exec(houseNumberField.val())[0].trim(),
url = settings.dutchAddressLookup + postcode + '/' + houseNumber;
url = settings.dutchAddressLookup + postcode + '/' + encodeURIComponent(encodeURIComponent(houseNumber));

resetHouseNumberSelect();
resetAddressFields(addressFields);
Expand Down Expand Up @@ -396,6 +396,13 @@
context: (countryIsoMap.get(countryToState.val()) || 'nld').toLowerCase(),
});

const getSuggestions = autocompleteInstance.getSuggestions;

autocompleteInstance.getSuggestions = function () {
arguments[1] = encodeURIComponent(arguments[1]); // Term needs double encoding because of autodecoding of superglobals.
getSuggestions.apply(this, arguments);
}

intlField[0].addEventListener('autocomplete-select', function (e) {
if (e.detail.precision === 'Address')
{
Expand Down
2 changes: 1 addition & 1 deletion postcodenl-address-autocomplete.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Plugin Name: Postcode.nl Address Autocomplete
* Plugin URI: https://www.postcode.nl/en/services/adresdata/implementatie
* Description: Reference implementation for Postcode.nl international address autocomplete for WooCommerce
* Version: 2.0.1
* Version: 2.0.2
* Author: Postcode.nl
* Author URI: https://www.postcode.nl
* Text Domain: postcodenl-address-autocomplete
Expand Down
2 changes: 1 addition & 1 deletion src/PostcodeNl/AddressAutocomplete/Main.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
class Main
{
/** @var string The version number of the plugin should be equal to the commented version number in ../../../postcodenl-address-autocomplete.php */
public const VERSION = '2.0.1';
public const VERSION = '2.0.2';

/** @var self Reference to own */
protected static $_instance;
Expand Down
2 changes: 2 additions & 0 deletions src/PostcodeNl/AddressAutocomplete/Proxy.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public function autocomplete(): void
{
$this->_populateSession();
[$context, $term] = $this->_getParameters(2);
$term = wp_check_invalid_utf8(rawurldecode($term));

try
{
Expand Down Expand Up @@ -72,6 +73,7 @@ public function getDetails(): void
public function dutchAddressLookup(): void
{
[$postcode, $houseNumberAndAddition] = $this->_getParameters(2);
$houseNumberAndAddition = wp_check_invalid_utf8(rawurldecode($houseNumberAndAddition));

preg_match('/^(?<houseNumber>\d{1,5})(?<addition>\D.*)?$/', $houseNumberAndAddition, $matches);
$houseNumber = isset($matches['houseNumber']) ? (int)$matches['houseNumber'] : null;
Expand Down

0 comments on commit 8af1606

Please sign in to comment.