Bug 1007529 - Using single quote inside double quotes followed by 'update()' results in 'String index out of range' exception
Summary: Using single quote inside double quotes followed by 'update()' results in 'St...
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: JBoss BRMS Platform 6
Classification: Retired
Component: BRE
Version: 6.0.0
Hardware: Unspecified
OS: Unspecified
unspecified
medium
Target Milestone: ER4
: 6.0.0
Assignee: Mario Fusco
QA Contact: Petr Široký
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2013-09-12 16:59 UTC by Petr Široký
Modified: 2014-08-06 20:19 UTC (History)
0 users

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2014-08-06 20:19:08 UTC
Type: Bug


Attachments (Terms of Use)

Description Petr Široký 2013-09-12 16:59:09 UTC
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 21:11:06 UTC
PR with the test: https://github.com/droolsjbpm/drools/pull/252

Comment 6 Petr Široký 2013-10-17 16:21:18 UTC
Verified fixed in ER4.


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