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

SDK doesn't handle Unicode control characters. #490

Open
jicoop opened this issue Mar 11, 2023 · 2 comments
Open

SDK doesn't handle Unicode control characters. #490

jicoop opened this issue Mar 11, 2023 · 2 comments
Labels

Comments

@jicoop
Copy link

jicoop commented Mar 11, 2023

Basically I have a code that does this:

    private final DbxUserFilesRequests files;

    @SneakyThrows
    public Metadata getMetadata(String path) {
        return files.getMetadata(path);
    }

This works for normal paths that don't contain control characters.

However, if you supply path that contains the Unicode Control Characters that aren't escaped:

/SomeFolder/acces
s_token.txt

It spits out this issue:

 java.lang.IllegalArgumentException: String 'path' does not match pattern
    at com.dropbox.core.v2.files.GetMetadataArg.<init>(GetMetadataArg.java:58)
    at com.dropbox.core.v2.files.GetMetadataArg.<init>(GetMetadataArg.java:80)
    at com.dropbox.core.v2.files.DbxUserFilesRequests.getMetadata(DbxUserFilesRequests.java:1602)

But if you escape the path from unicode characters like this:

acces\u2028s_token.txt

It seems that the library escapes the backslash character, and causes the API to return the Malformed path response.

    "error": {
        ".tag": "path",
        "path": {
            ".tag": "malformed_path"
        }
    }

Unfortunately, I don't really have a choice in renaming the file. Is there a solution we can have to handle the unicode control? Like another method that allows us to supply a string that won't be processed by the SDK?

I know from cURL, it's possible to use the escaped form of the unicode character and get the metadata. However, it's just not a choice I have from the java SDK since it won't do it for me, and it doesn't like the escaped version of unicode.

@greg-db
Copy link
Contributor

greg-db commented Mar 13, 2023

Thanks for the detailed post. It looks like this may just be a bug in the Java SDK. I'll ask the team to look into it.

@devPalacio
Copy link
Contributor

I filed an issue with the stone repo, since the regex we're currently using is what is causing the IllegalArgumentException in our generated code.

@devPalacio devPalacio added the bug label Jul 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants