Uploaded image for project: 'PUBLIC - Liferay Portal Community Edition'
  1. PUBLIC - Liferay Portal Community Edition
  2. LPS-45109

Infinite-loop in StringUtil.replace(String s, String begin, String end, Map<String, String> values)

    Details

      Description

      Step to reproduce:

      1. Execute the following code at Control Panel/Server Admin/Script tab as a Groovy script:
        import com.liferay.portal.kernel.util.StringUtil
        import java.util.Map;
        import java.util.HashMap;
        
        		final Map<String, String> map = new HashMap<String, String>();
        		
                        map.put("a", "X");
        		map.put("b", "Y");
        		map.put("c", "Z");
        		map.put("d", "Q");
        
        		System.out.println("Start...");
        		System.out.println(StringUtil.replace("abcd_abcd", "", "", map));
        		System.out.println("End.");
        

      Result: Infinite-loop, thus the "End." string won't be written in the console.
      Expected: The API should avoid infinite-loop situations e.g. by checking the input parameters with Validator.isNull() method instead the direct null checking.

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Days since last comment:
                  5 years, 3 weeks, 2 days ago