dropbox / dropbox/dropbox-sdk-java

SDK doesn't handle Unicode control characters.

Aperta
#490 2 commenti 0 reazioni 0 assegnatari Vedi su GitHub
bug
Lingua principale
Java
Stelle
627
Fork
463
Merge medio
5m
PR unite (30g)
10

Descrizione

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.(GetMetadataArg.java:58)
at com.dropbox.core.v2.files.GetMetadataArg.(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.

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Direzione di ricerca

Inizia con i costruttori di GetMetadataArg e la chiamata DbxUserFilesRequests.getMetadata mostrati nello stack trace, quindi segui la convalida del pattern del percorso. Riproduci il percorso U+2028 non sottoposto a escape e confrontalo con l'input sottoposto a escape; l'attività è completata quando Java SDK accetta il percorso Unicode effettivo e lo invia all'API senza trattare il testo di escape come una sequenza letterale di backslash.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
java
Ambito
api
Tipo di issue
Bug
Difficoltà
3/5
Tempo stimato
1-2 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
35/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.