jira.codehaus.org

  • Log In Access more options
    • Online Help
    • Keyboard Shortcuts
    • About JIRA
    • JIRA Credits
    • What?s New
  • Dashboards Access more options (Alt+d)
  • Projects Access more options (Alt+p)
  • Issues Access more options (Alt+i)
  • groovy
  • GROOVY-3536

multi / single line regular expression infinite loop

  • Log In
  • Views
    • XML
    • Word
    • Printable

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Won't Fix
  • Affects Version/s: 1.6.2
  • Fix Version/s: None
  • Component/s: regular expressions
  • Labels:
    None
  • Environment:
    windows xp sp3 x64

Description

//groovy version 1.6.2
//this script seems to go on an infinite loop in the last line 

def str = '''ID_843110_DATE
2008-08-26 02:53:25
ID_843110_SRC
This is a test
ID_843110_TRG
Aceasta este o incercare
'''

def id = 843110

def m = str =~ /(?s)^ID_($id)_DATE\n.*\nID_($id)_SRC\n(.*\n)+ID_($id)_TRG\n(.*\n)+/

m.each { println it }
 
m = str =~ /(?s)^ID_($id)_DATE\n.*\nID_($id)_SRC\n(.*)+ID_($id)_TRG\n(.*\n)+/

m.each{ println it }

Activity

Ascending order - Click to sort in descending order
  • All
  • Comments
  • Work Log
  • History
  • Activity
Hide
Permalink
Paul King added a comment - 18/Jun/09 2:34 AM

This is present in Java too:

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main {
    public static void main(String[] args) {
        String str = "ID_843110_DATE\n" +
"2008-08-26 02:53:25\n" +
"ID_843110_SRC\n" +
"This is a test\n" +
"ID_843110_TRG\n" +
"Aceasta este o incercare\n";

        int id = 843110;

        String regex = "(?s)^ID_(" + id + ")_DATE\\n.*\\nID_(" + id + ")_SRC\\n(.*)+ID_(" + id + ")_TRG\\n(.*\\n)+";
        Matcher m = Pattern.compile(regex).matcher(str);
        System.out.println("m.matches() = " + m.matches());
    }
}

And from looking at the Java bug database, it doesn't seem like Java tries to police such dangerous expressions, e.g.:
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4704828

Show
Paul King added a comment - 18/Jun/09 2:34 AM This is present in Java too:
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main {
    public static void main(String[] args) {
        String str = "ID_843110_DATE\n" +
"2008-08-26 02:53:25\n" +
"ID_843110_SRC\n" +
"This is a test\n" +
"ID_843110_TRG\n" +
"Aceasta este o incercare\n";

        int id = 843110;

        String regex = "(?s)^ID_(" + id + ")_DATE\\n.*\\nID_(" + id + ")_SRC\\n(.*)+ID_(" + id + ")_TRG\\n(.*\\n)+";
        Matcher m = Pattern.compile(regex).matcher(str);
        System.out.println("m.matches() = " + m.matches());
    }
}
And from looking at the Java bug database, it doesn't seem like Java tries to police such dangerous expressions, e.g.: http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4704828
Hide
Permalink
blackdrag blackdrag added a comment - 18/Jun/09 9:02 AM

this means we should close the issue?

Show
blackdrag blackdrag added a comment - 18/Jun/09 9:02 AM this means we should close the issue?
Hide
Permalink
Paul King added a comment - 18/Jun/09 6:16 PM

Our options are:

  1. ignore the issue because Java does
  2. find a work around for the existing library (I can't think of one though)
  3. substitute a different library

I guess I am in favor of the first of these so long as we document the kind of things to look out for that might cause grief with the current Java libraries and document how to use some of the other available libraries. I.e. change this from bug to documentation enhancement.

Show
Paul King added a comment - 18/Jun/09 6:16 PM Our options are:
  1. ignore the issue because Java does
  2. find a work around for the existing library (I can't think of one though)
  3. substitute a different library
I guess I am in favor of the first of these so long as we document the kind of things to look out for that might cause grief with the current Java libraries and document how to use some of the other available libraries. I.e. change this from bug to documentation enhancement.
Hide
Permalink
Paul King added a comment - 26/Dec/10 3:46 AM

Closing for now unless a definite proposal is submitted. Users running into this issue will likely find this issue and deduce the problem, i.e. their incorrect usage of the underlying api.

Show
Paul King added a comment - 26/Dec/10 3:46 AM Closing for now unless a definite proposal is submitted. Users running into this issue will likely find this issue and deduce the problem, i.e. their incorrect usage of the underlying api.

People

  • Assignee:
    Paul King
    Reporter:
    Arun Ramakrishnan
Vote (0)
Watch (1)

Dates

  • Created:
    19/May/09 10:44 PM
    Updated:
    26/Dec/10 3:47 AM
    Resolved:
    26/Dec/10 3:46 AM
  • Atlassian JIRA (v5.0.4#731-sha1:3aa7374)
  • Report a problem
  • Powered by a free Atlassian JIRA open source license for Codehaus. Try JIRA - bug tracking software for your team.