From d5e7f174d01ade1c4aee15fa13c6afeff191fd6c Mon Sep 17 00:00:00 2001 From: Bas Leijdekkers Date: Tue, 6 Aug 2019 08:40:35 +0200 Subject: [PATCH] regexp: fix NumberFormatException in php (EA-122197) GitOrigin-RevId: a082b799b351e13d656a10efd350323986dd4b04 --- .../lang/regexp/RegExpLanguageHost.java | 2 +- .../com/intellij/psi/impl/JavaRegExpHost.java | 18 ++---------------- .../impl/PyStringLiteralExpressionImpl.java | 18 ++---------------- 3 files changed, 5 insertions(+), 33 deletions(-) diff --git a/RegExpSupport/src/org/intellij/lang/regexp/RegExpLanguageHost.java b/RegExpSupport/src/org/intellij/lang/regexp/RegExpLanguageHost.java index 4bec8b86a659..ba6cf67b2795 100644 --- a/RegExpSupport/src/org/intellij/lang/regexp/RegExpLanguageHost.java +++ b/RegExpSupport/src/org/intellij/lang/regexp/RegExpLanguageHost.java @@ -94,7 +94,7 @@ public interface RegExpLanguageHost { */ @Nullable default Number getQuantifierValue(@NotNull RegExpNumber number) { - return Double.parseDouble(number.getText()); + return Double.parseDouble(number.getUnescapedText()); } default Lookbehind supportsLookbehind(@NotNull RegExpGroup lookbehindGroup) { diff --git a/java/java-impl/src/com/intellij/psi/impl/JavaRegExpHost.java b/java/java-impl/src/com/intellij/psi/impl/JavaRegExpHost.java index 43cc34b7e4bb..883342f2904b 100644 --- a/java/java-impl/src/com/intellij/psi/impl/JavaRegExpHost.java +++ b/java/java-impl/src/com/intellij/psi/impl/JavaRegExpHost.java @@ -1,18 +1,4 @@ -/* - * Copyright 2000-2017 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.psi.impl; import com.intellij.openapi.module.Module; @@ -346,7 +332,7 @@ public class JavaRegExpHost implements RegExpLanguageHost { @Override public Integer getQuantifierValue(@NotNull RegExpNumber number) { try { - return Integer.valueOf(number.getText()); + return Integer.valueOf(number.getUnescapedText()); } catch (NumberFormatException e) { return null; diff --git a/python/src/com/jetbrains/python/psi/impl/PyStringLiteralExpressionImpl.java b/python/src/com/jetbrains/python/psi/impl/PyStringLiteralExpressionImpl.java index 59478edaa4dd..17cbcbf62e58 100644 --- a/python/src/com/jetbrains/python/psi/impl/PyStringLiteralExpressionImpl.java +++ b/python/src/com/jetbrains/python/psi/impl/PyStringLiteralExpressionImpl.java @@ -1,18 +1,4 @@ -/* - * Copyright 2000-2017 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.jetbrains.python.psi.impl; import com.intellij.icons.AllIcons; @@ -392,7 +378,7 @@ public class PyStringLiteralExpressionImpl extends PyElementImpl implements PySt @Override public Long getQuantifierValue(@NotNull RegExpNumber number) { try { - final long result = Long.parseLong(number.getText()); + final long result = Long.parseLong(number.getUnescapedText()); if (result >= 0xFFFFFFFFL /* max unsigned int 32 bits */) return null; return result; }