github-advanced-security[bot] commented on code in PR #203:
URL: https://github.com/apache/roller/pull/203#discussion_r4174053505


##########
app/src/main/java/org/apache/roller/weblogger/util/InlineImageData.java:
##########
@@ -0,0 +1,156 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+package org.apache.roller.weblogger.util;
+
+import java.util.ArrayList;
+import java.util.Base64;
+import java.util.List;
+import java.util.Locale;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/** Image data URLs accepted in entry content and their locations in HTML. */
+public final class InlineImageData {
+
+    // MySQL's TEXT column holds 65,535 bytes. Leave room for the rest of an 
entry.
+    public static final int MAX_FIELD_BYTES = 60000;
+
+    private static final Pattern IMAGE_TAG = 
Pattern.compile("(?is)<img\\b[^>]*>");
+    private static final Pattern SOURCE_ATTRIBUTE = Pattern.compile(
+            
"(?is)(?<![\\w:-])src\\s*=\\s*(?:\"([^\"]*)\"|'([^']*)'|([^\\s>]+))");
+    private static final Pattern DATA_URL = Pattern.compile(
+            "(?i)^data:image/(png|jpeg|gif);base64,([a-z0-9+/]+={0,2})$");
+
+    private InlineImageData() {
+    }
+
+    public static List<Source> findSources(String html) {
+        List<Source> sources = new ArrayList<>();
+        if (html == null) {
+            return sources;
+        }
+        Matcher image = IMAGE_TAG.matcher(html);

Review Comment:
   ## CodeQL / Polynomial regular expression used on uncontrolled data
   
   This [regular expression](1) that depends on a [user-provided value](2) may 
run slow on strings starting with '<imgb' and with many repetitions of '<imgb'.
   
   [Show more 
details](https://github.com/apache/roller/security/code-scanning/132)



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to