[gnome-maps] place: Guard against invalid regex
- From: Jonas Danielsson <jonasdn src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-maps] place: Guard against invalid regex
- Date: Mon, 29 Aug 2016 16:55:25 +0000 (UTC)
commit 15c5227ab53a636ddba8cb95f965ab41bb2fa02d
Author: Jonas Danielsson <jonas threetimestwo org>
Date: Mon Aug 29 18:50:30 2016 +0200
place: Guard against invalid regex
Avoid errors in console when string is not valid regex.
SyntaxError: invalid quantifier @ place.js:264
src/place.js | 8 +++++++-
1 files changed, 7 insertions(+), 1 deletions(-)
---
diff --git a/src/place.js b/src/place.js
index 0d85b96..aa60f55 100644
--- a/src/place.js
+++ b/src/place.js
@@ -260,7 +260,13 @@ const Place = new Lang.Class({
if (name === null)
return false;
- return name.toLowerCase().search(searchString.toLowerCase()) !== -1;
+ /* the search method takes a regex, make sure we have a valid one */
+ try {
+ return name.toLowerCase().search(searchString.toLowerCase()) !== -1;
+ } catch(e) {
+ /* not valid regex */
+ return false;
+ }
}
});
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]