Skip to content

KopiLua string.gsub() "pattern too complex" error, update KopiLua_strlib? #318

@admalledd

Description

@admalledd

Reproduction lua, this should not throw/error. It is a valid regex and source string. There is some bug in the old-old (2015?) KopiLua_strlib.cs and it is loosing track of the input state.

var code = "string.gsub('some words for spacing error reasons <script>alert(""hello world"")</script>','^%s*(.-)%s*$','%1')";
var script = new Script();
script.DoString(code); //should not throw in this case

Sample code came after reproducing and narrowing some live-ish code I found while doing a security audit on regex complexities.

Upstream KopiLua seems to have an older PR that may fix this? https://github.com/NLua/KopiLua/pull/21/files but I haven't had a chance to merge-refactor it in to our local moonsharp fork yet.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions