Opened 2 years ago

Last modified 20 months ago

#5457 new defect

Compiler scanner allows any char to be escaped in strings

Reported by: jsten Owned by: Jesper Mattsson
Priority: major Milestone:
Component: Modelica/FrontEnd Version: trunk
Keywords: Cc:

Description (last modified by jsten)

Currently the Modelica (and Optimica) scanner allows any char to be escaped in strings. This is however not allowed according to specification:

STRING = """ { S-CHAR | S-ESCAPE } """
S-CHAR = any member of the Unicode character set (; see section 13.2.2 for storing as UTF-8 on files) except double-quote """, and backslash "\"
S-ESCAPE = "\’" | "\"" | "\?" | "\\" | "\a" | "\b" | "\f" | "\n" | "\r" | "\t" | "\v"

We should update our scanner so that it only accepts allowed characters and give a parser error if the character isn't allowed! Normally this isn't a problem, but in some situations it causes OCT to crash since it expects certain characters! On the other hand we should change so that we handle it more gracefully, i.e. ASTNode.unEscape(String str) currently throws exception for the following code:

        ClassDecl cd = sr.getProgram().simpleLookupClassDotted("<model with incorrect char in Documentation/info annotation>");
        AnnotationNode annoNode = cd.annotation("Documentation/info");

Change History (3)

comment:1 Changed 2 years ago by jsten

Description: modified (diff)

comment:2 Changed 2 years ago by Christian Andersson

Milestone: 2.1.x2.2.x

comment:3 Changed 20 months ago by Christian Andersson

Milestone: 2.2.x

Ticket retargeted after milestone closed

Note: See TracTickets for help on using tickets.