Skip to content

[SR-8678] Possible security fail in implementation of multiline/delimited strings #51192

Open
@johnno1962

Description

@johnno1962
Previous ID SR-8678
Radar None
Original Reporter @johnno1962
Type Bug
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, Parser
Assignee None
Priority Medium

md5: 649261c2424597aabda9e63a57de79a9

Issue Description:

As was pointed out in the tail end of the discussion of SE-200 there is a potential security problem with multiple character string delimiters as are used by multiline strings and soon to be implemented “raw/delimited strings” as demonstrated by the following contrived code:

print("""
Validating password...
"​"")
guard user.validatePassword(password) else {
    fatalError("get out!")
}
print("​""
Password is valid!
""")

It contains a zero-width unicode character in the first closing delimiter so this code is treated as one string. In Xcode this mitigated by being syntax highlighted correctly but perhaps there is something here that deserves attention. A possible fix for this is included in the last commit on #17668

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfparserArea → compiler: The legacy C++ parser

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions