You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- This example defaults to <kbd>Dynamic (all code pages supported)</kbd>.
45
-
- When set to <kbd>Dynamic (all code pages supported)</kbd> (`FATFS_CODEPAGE_DYNAMIC`), FATFS will support all code pages, but will increase the compiled binary size by ~500kB.
46
-
-When set to other code pages, you need to select a code page that matches the character set of the filenames, otherwise it may cause garbled characters, inability to find files, or other hidden issues.
45
+
- When set to <kbd>Dynamic (all code pages supported)</kbd> (`FATFS_CODEPAGE_DYNAMIC`), FATFS will support all code pages, but it will increase the size of the compiled output by about 500 kB.
46
+
-If you choose another code page, make sure that the selected code page matches the character set used in the filenames; otherwise it may cause garbled text, file not found errors, or other latent issues.
Copy file name to clipboardExpand all lines: examples/usb/host/usb_host_msc_example/README.md
+13Lines changed: 13 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -15,6 +15,19 @@ This example demonstrates how to use USB Host MSC functionality and provides a w
15
15
16
16
Note: exFat requires a paid license.
17
17
18
+
### FATFS Multilingual Filename Support (Enabled by Default)
19
+
20
+
This demo has enabled FATFS OEM multi-code page support. To manually adjust multi-language support for filenames, please adjust the following options in menuconfig:
- This example defaults to <kbd>Dynamic (all code pages supported)</kbd>.
24
+
- When set to <kbd>Dynamic (all code pages supported)</kbd> (`FATFS_CODEPAGE_DYNAMIC`), FATFS will support all code pages, but it will increase the size of the compiled output by about 500 kB.
25
+
- If you choose another code page, make sure that the selected code page matches the character set used in the filenames; otherwise it may cause garbled text, file not found errors, or other latent issues.
Copy file name to clipboardExpand all lines: examples/usb/host/usb_host_msc_example/components/app_file_web/spiffs/upload.html
+31-9Lines changed: 31 additions & 9 deletions
Original file line number
Diff line number
Diff line change
@@ -124,31 +124,53 @@
124
124
validateInputs();
125
125
}
126
126
127
+
// Calculate UTF-8 byte length of a string
128
+
functiongetByteLength(str){
129
+
returnnewTextEncoder().encode(str).length;
130
+
}
131
+
132
+
// Check for invalid filesystem characters
133
+
functionhasInvalidPathChars(path){
134
+
// Invalid characters for paths: control chars, <, >, :, ", |, ?, *, \
135
+
return/[\x00-\x1f<>:"|?*\\]/.test(path);
136
+
}
137
+
138
+
functionhasInvalidFileNameChars(fileName){
139
+
// Invalid characters for filenames: control chars, <, >, :, ", |, ?, *, \, /
140
+
return/[\x00-\x1f<>:"|?*\\/]/.test(fileName);
141
+
}
142
+
127
143
functionvalidateInputs(){
128
144
constuploadPath=uploadPathInput.value;
129
145
constfileName=fileNameInput.value;
130
-
146
+
// Validate upload path
131
147
if(
132
148
!uploadPath.startsWith("/")||
133
149
!uploadPath.endsWith("/")||
134
-
/[^a-zA-Z0-9\.\/\_\-]/.test(uploadPath)||
150
+
hasInvalidPathChars(uploadPath)||
135
151
uploadPath.startsWith("/upload/")||
136
152
uploadPath.startsWith("/api/")||
137
-
/\/\//.test(uploadPath)
153
+
/\/\//.test(uploadPath)||
154
+
getByteLength(uploadPath)>255
138
155
){
139
-
pathError.textContent="Invalid upload path.";
156
+
pathError.textContent="Invalid upload path. Path must start and end with /, contain no invalid characters, not exceed 255 bytes, and not start with /upload/ or /api/.";
140
157
}else{
141
158
pathError.textContent="";
142
159
}
143
-
160
+
// Validate file name
144
161
if(
145
-
/[^a-zA-Z0-9\.\_\-]/.test(fileName)||
146
-
fileName.length>32||
162
+
hasInvalidFileNameChars(fileName)||
163
+
getByteLength(fileName)>64||
147
164
fileName==="upload.html"||
148
165
fileName==="api"||
149
-
fileName==="settings.html"
166
+
fileName==="settings.html"||
167
+
fileName.trim()!==fileName||
168
+
fileName.endsWith(".")||
169
+
fileName===""||
170
+
fileName==="."||
171
+
fileName===".."
150
172
){
151
-
nameError.textContent="Invalid file name.";
173
+
nameError.textContent="Invalid file name. Must not contain invalid characters (< > : \" | ? * \\ /), not exceed 64 bytes, and not be a reserved name.";
0 commit comments