From 1a3094ed6d0d9f0122f9ea62a35ca4a1f8cd724f Mon Sep 17 00:00:00 2001 From: Semyon Proshev Date: Fri, 8 Apr 2016 16:54:29 +0300 Subject: [PATCH] PY-19075 Fixed: PyCharm 2016.1.1 freezes immediately after the update SQL injection heavy cases tests have been added, limit injected string literal with 10K symbols --- .../src/com/jetbrains/python/patterns/PythonPatterns.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/python/src/com/jetbrains/python/patterns/PythonPatterns.java b/python/src/com/jetbrains/python/patterns/PythonPatterns.java index fb6a8de4feef..2d6dc0baceb8 100644 --- a/python/src/com/jetbrains/python/patterns/PythonPatterns.java +++ b/python/src/com/jetbrains/python/patterns/PythonPatterns.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2014 JetBrains s.r.o. + * Copyright 2000-2016 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. @@ -34,6 +34,9 @@ import java.util.regex.Pattern; * @author yole */ public class PythonPatterns extends PlatformPatterns { + + private static final int STRING_LITERAL_LIMIT = 10000; + public static PyElementPattern.Capture pyLiteralExpression() { return new PyElementPattern.Capture(new InitialPatternCondition(PyLiteralExpression.class) { public boolean accepts(@Nullable final Object o, final ProcessingContext context) { @@ -49,7 +52,7 @@ public class PythonPatterns extends PlatformPatterns { public boolean accepts(@Nullable Object o, ProcessingContext context) { if (o instanceof PyStringLiteralExpression) { final PyStringLiteralExpression expr = (PyStringLiteralExpression)o; - if (!DocStringUtil.isDocStringExpression(expr)) { + if (!DocStringUtil.isDocStringExpression(expr) && expr.getTextLength() < STRING_LITERAL_LIMIT) { final String value = expr.getStringValue(); return pattern.matcher(value).find(); }