Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flexible prefix in the forced subject regex #96

Open
SoraSuegami opened this issue Dec 7, 2024 · 3 comments
Open

Flexible prefix in the forced subject regex #96

SoraSuegami opened this issue Dec 7, 2024 · 3 comments

Comments

@SoraSuegami
Copy link
Contributor

SoraSuegami commented Dec 7, 2024

We are working to make the prefix in the forced subject regex more flexible, ensuring it remains agnostic to any prefix added in reply emails.
I attempted the following three patterns, but all of them failed to compile with the error: 'Failed to build DFA for regex: "", please check your regex. Error: error building NFA", which occurs in regex-automata library depended by the zk-regex compiler. (The in the error is the regex string of the decomposed part including "[^[]*" for each decomposed regex.)

{
    "parts": [
        {
            "is_public": false,
            "regex_def": "(\r\n|^)subject:"
        },
        {
            "is_public": false,
            "regex_def": "[^[]*"
        },
        {
            "is_public": false,
            "regex_def": "\\[Reply Needed\\][^\r\n]*\r\n"
        }
    ]
}
{
    "parts": [
        {
            "is_public": false,
            "regex_def": "(\r\n|^)subject:[^[]*"
        },
        {
            "is_public": false,
            "regex_def": "\\[Reply Needed\\][^\r\n]*\r\n"
        }
    ]
}
{
    "parts": [
        {
            "is_public": false,
            "regex_def": "(\r\n|^)subject:[^[]*\\[Reply Needed\\][^\r\n]*\r\n"
        }
    ]
}
@SoraSuegami
Copy link
Contributor Author

When I tried "[^\[]" instead of "[^[]", I got a parse error because \ is unnecessary in the negation regex.

@Divide-By-0
Copy link
Member

And if you double the backslash?

https://docs.prove.email/zk-email-sdk/create-blueprint quotes:

Some characters need to be escaped in the regex. For example, the " character needs to be escaped as ". This way when the JSON is parsed, it is not confused with the JSON syntax.

Also all the regex reserved characters need to be escaped twice. For example, the . character needs to be escaped as \.. One for the JSON parser and one for the regex engine.

@SoraSuegami
Copy link
Contributor Author

SoraSuegami commented Dec 7, 2024

Sorry for the confusion.

When I tried "[^\[]" instead of "[^[]", I got a parse error because \ is unnecessary in the negation regex.

This means I tried the double backslash in the decomposed json as a single \ was not permitted in a JSON syntax.
However, I got the error Error: Parse Error: Invalid character: \\.
I think we need to modify the zk-regex compiler.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants