Bug 1007529 - Using single quote inside double quotes followed by 'update()' results in 'String index out of range' exception
Using single quote inside double quotes followed by 'update()' results in 'St...
Status: CLOSED CURRENTRELEASE
Product: JBoss BRMS Platform 6
Classification: JBoss
Component: BRE (Show other bugs)
6.0.0
Unspecified Unspecified
unspecified Severity medium
: ER4
: 6.0.0
Assigned To: Mario Fusco
Petr Široký
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2013-09-12 12:59 EDT by Petr Široký
Modified: 2014-08-06 16:19 EDT (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2014-08-06 16:19:08 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Petr Široký 2013-09-12 12:59:09 EDT
Description of problem:
Using single quote only once (not in pair) inside double qouotes (e.g. "Some string with single _'_ quote") and followed by an 'update()' results in java.lang.StringIndexOutOfBoundsException. See example DRL below to reproduce the issue. I will create PR with the test case that can be merged into Drools.
 

Sample DRL:
declare Person
    name: String
end

rule "test"
when
    $p: Person()
then
    $p.setName("Some name with' single quote inside");
    update($p);
end


Stacktrace:
java.lang.StringIndexOutOfBoundsException: String index out of range: -9
	at java.lang.String.substring(String.java:1937)
	at org.drools.compiler.rule.builder.dialect.DialectUtil.parseModifiedProperties(DialectUtil.java:716)
	at org.drools.compiler.rule.builder.dialect.DialectUtil.rewriteUpdateDescr(DialectUtil.java:683)
	at org.drools.compiler.rule.builder.dialect.DialectUtil.rewriteDescr(DialectUtil.java:592)
	at org.drools.compiler.rule.builder.dialect.DialectUtil.fixBlockDescr(DialectUtil.java:151)
	at org.drools.compiler.rule.builder.dialect.DialectUtil.fixBlockDescr(DialectUtil.java:109)
	at org.drools.compiler.rule.builder.dialect.asm.AbstractASMConsequenceBuilder.consequenceContext(AbstractASMConsequenceBuilder.java:44)
	at org.drools.compiler.rule.builder.dialect.asm.AbstractASMConsequenceBuilder.build(AbstractASMConsequenceBuilder.java:20)
	at org.drools.compiler.rule.builder.RuleBuilder.build(RuleBuilder.java:103)
	at org.drools.compiler.compiler.PackageBuilder.addRule(PackageBuilder.java:3160)
	at org.drools.compiler.compiler.PackageBuilder.compileRules(PackageBuilder.java:1047)
	at org.drools.compiler.compiler.PackageBuilder.compileAllRules(PackageBuilder.java:952)
	at org.drools.compiler.compiler.CompositeKnowledgeBuilderImpl.buildRules(CompositeKnowledgeBuilderImpl.java:231)
	at org.drools.compiler.compiler.CompositeKnowledgeBuilderImpl.buildPackages(CompositeKnowledgeBuilderImpl.java:86)
	at org.drools.compiler.compiler.CompositeKnowledgeBuilderImpl.build(CompositeKnowledgeBuilderImpl.java:75)
	at org.drools.compiler.kie.builder.impl.AbstractKieModule.buildKnowledgePackages(AbstractKieModule.java:205)
	at org.drools.compiler.kie.builder.impl.AbstractKieProject.verify(AbstractKieProject.java:39)
	at org.drools.compiler.kie.builder.impl.KieBuilderImpl.buildKieModule(KieBuilderImpl.java:297)
	at org.drools.compiler.kie.builder.impl.KieBuilderImpl.buildAll(KieBuilderImpl.java:182)
	at org.kie.internal.utils.KieHelper.build(KieHelper.java:44)


Version-Release number of selected component (if applicable):
Community 6.1.0-SNAPSHOT


Actual results:
StringIndexOutOfBoundsException thrown.


Expected results:
DRL should be successfully parsed.


Additional info: This comes from customer's use case so we need to fix it in 6.0.
Comment 1 Petr Široký 2013-09-12 17:11:06 EDT
PR with the test: https://github.com/droolsjbpm/drools/pull/252
Comment 6 Petr Široký 2013-10-17 12:21:18 EDT
Verified fixed in ER4.

Note You need to log in before you can comment on or make changes to this bug.