Bug 44154 - Error while using Perl5Util.substitute() method if it has "/" character.
Summary: Error while using Perl5Util.substitute() method if it has "/" character.
Status: CLOSED INVALID
Alias: None
Product: ORO
Classification: Unclassified
Component: Main (show other bugs)
Version: Unknown
Hardware: Other other
: P2 critical (vote)
Target Milestone: ---
Assignee: Jakarta Notifications Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-12-31 06:51 UTC by Satya Sai Rama Krishna
Modified: 2007-12-31 10:38 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Satya Sai Rama Krishna 2007-12-31 06:51:23 UTC
Hi Experts,

Iam facing an issue in one of my java applications.

We are using Java tool to update the information from frontend.

If the notes contain "/" slash character, application is throwing the below 
error : 

org.apache.oro.text.perl.MalformedPerl5PatternException: Invalid option: N
at org.apache.oro.text.perl.Perl5Util.substitute(Unknown Source)..


body = substituteWith(util, body, "Notes", notes);


protected static String substituteWith(Perl5Util util, String b, String c,
			String v) {

		return util.substitute("s/#" + c + "#/" + (v != null ? 
v : " ") + "/g", b);
	}

Any pointers on this issue or its an identified bug.

Thanks in Advance!
Wish You A HAPPY NEW YEAR !!!

Thanks & Regards,
Satya Sai
Comment 1 Daniel F. Savarese 2007-12-31 10:38:24 UTC
You're creating an invalid expression.  It works exactly the same way in Perl.
If your foo and/or bar within /foo/bar/ contains /, either use a different
character than / that isn't contained in foo and bar or escape all the /'s in
foo and bar.  You may find it more appropriate to use
org.apache.oro.text.regex.Util.substitute, where you don't have to worry about
the contents of the substitution and can scrub a dynamically generated pattern
with Perl5Compiler.quotemeta before compiling it.

You can get support via the oro-user mailing list first before reporting a bug
through the issue tracking system.