catamphetamine / libphonenumber-js

A simpler (and smaller) rewrite of Google Android's libphonenumber library in javascript
https://catamphetamine.gitlab.io/libphonenumber-js/
MIT License
2.79k stars 216 forks source link

libphonenumber-js error when used with Google reCaptcha in IE11 #255

Closed ahmed-hyd closed 6 years ago

ahmed-hyd commented 6 years ago

Hi,

While using libphonenumber-js along with Google reCaptcha, we are getting the error "Exception thrown and not caught" on the function replace_characters. This issue is happening only on newer versions of IE11 on Windows OS.

I have uploaded a POC here.

IE version used: 11.0.9600.18130

Please suggest how we can mitigate this.

Thanks, Ahmed M

catamphetamine commented 6 years ago

There's no replace_characters function in this library.

ahmed-hyd commented 6 years ago

The problem is occurring when I am making the following call

const asYouTypes = new asYouType(this.state.country); const text = asYouTypes.input(value);

The exception seems to be occurring in the following auto-generated javascript function

` function replace_characters(text, replacements) { var replaced = '';

var _iteratorNormalCompletion2 = true;
var _didIteratorError2 = false;
var _iteratorError2 = undefined;

try {
    for (var _iterator2 = (0, _getIterator3.default)(text), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
        var character = _step2.value;

        var replacement = replacements[character.toUpperCase()];

        if (replacement !== undefined) {
            replaced += replacement;
        }
    }
} catch (err) {
    _didIteratorError2 = true;
    _iteratorError2 = err;
} finally {
    try {
        if (!_iteratorNormalCompletion2 && _iterator2.return) {
            _iterator2.return();
        }
    } finally {
        if (_didIteratorError2) {
            throw _iteratorError2;
        }
    }
}

return replaced;

}`