@@ -267,112 +267,8 @@ const uint8_t edit_htm_gz[] PROGMEM = {
267267};
268268
269269#define SPIFFS_MAXLENGTH_FILEPATH 32
270- const char *excludeListFile = " /.exclude.files" ;
271270
272- typedef struct ExcludeListS {
273- char *item;
274- ExcludeListS *next;
275- } ExcludeList;
276-
277- static ExcludeList *excludes = NULL ;
278-
279- static bool matchWild (const char *pattern, const char *testee) {
280- const char *nxPat = NULL , *nxTst = NULL ;
281-
282- while (*testee) {
283- if (( *pattern == ' ?' ) || (*pattern == *testee)){
284- pattern++;testee++;
285- continue ;
286- }
287- if (*pattern==' *' ){
288- nxPat=pattern++; nxTst=testee;
289- continue ;
290- }
291- if (nxPat){
292- pattern = nxPat+1 ; testee=++nxTst;
293- continue ;
294- }
295- return false ;
296- }
297- while (*pattern==' *' ){pattern++;}
298- return (*pattern == 0 );
299- }
300-
301- static bool addExclude (const char *item){
302- size_t len = strlen (item);
303- if (!len){
304- return false ;
305- }
306- ExcludeList *e = (ExcludeList *)malloc (sizeof (ExcludeList));
307- if (!e){
308- return false ;
309- }
310- e->item = (char *)malloc (len+1 );
311- if (!e->item ){
312- free (e);
313- return false ;
314- }
315- memcpy (e->item , item, len+1 );
316- e->next = excludes;
317- excludes = e;
318- return true ;
319- }
320-
321- static void loadExcludeList (fs::FS &_fs, const char *filename){
322- static char linebuf[SPIFFS_MAXLENGTH_FILEPATH];
323- fs::File excludeFile=_fs.open (filename, " r" );
324- if (!excludeFile){
325- // addExclude("/*.js.gz");
326- return ;
327- }
328- #ifdef ESP32
329- if (excludeFile.isDirectory ()){
330- excludeFile.close ();
331- return ;
332- }
333- #endif
334- if (excludeFile.size () > 0 ){
335- uint8_t idx;
336- bool isOverflowed = false ;
337- while (excludeFile.available ()){
338- linebuf[0 ] = ' \0 ' ;
339- idx = 0 ;
340- int lastChar;
341- do {
342- lastChar = excludeFile.read ();
343- if (lastChar != ' \r ' ){
344- linebuf[idx++] = (char ) lastChar;
345- }
346- } while ((lastChar >= 0 ) && (lastChar != ' \n ' ) && (idx < SPIFFS_MAXLENGTH_FILEPATH));
347-
348- if (isOverflowed){
349- isOverflowed = (lastChar != ' \n ' );
350- continue ;
351- }
352- isOverflowed = (idx >= SPIFFS_MAXLENGTH_FILEPATH);
353- linebuf[idx-1 ] = ' \0 ' ;
354- if (!addExclude (linebuf)){
355- excludeFile.close ();
356- return ;
357- }
358- }
359- }
360- excludeFile.close ();
361- }
362-
363- static bool isExcluded (fs::FS &_fs, const char *filename) {
364- if (excludes == NULL ){
365- loadExcludeList (_fs, excludeListFile);
366- }
367- ExcludeList *e = excludes;
368- while (e){
369- if (matchWild (e->item , filename)){
370- return true ;
371- }
372- e = e->next ;
373- }
374- return false ;
375- }
271+ /* Exclusion list feature not needed and omitted */
376272
377273// WEB HANDLER IMPLEMENTATION
378274
@@ -394,6 +290,7 @@ bool SPIFFSEditor::canHandle(AsyncWebServerRequest *request){
394290 if (request->hasParam (" list" ))
395291 return true ;
396292 if (request->hasParam (" edit" )){
293+ if (request->arg (" edit" ).indexOf (" wsec" ) > -1 ) return false ; // make sure wsec.json is not served
397294 request->_tempFile = _fs.open (request->arg (" edit" ), " r" );
398295 if (!request->_tempFile ){
399296 return false ;
@@ -406,6 +303,7 @@ bool SPIFFSEditor::canHandle(AsyncWebServerRequest *request){
406303#endif
407304 }
408305 if (request->hasParam (" download" )){
306+ if (request->arg (" download" ).indexOf (" wsec" ) > -1 ) return false ; // make sure wsec.json is not served
409307 request->_tempFile = _fs.open (request->arg (" download" ), " r" );
410308 if (!request->_tempFile ){
411309 return false ;
@@ -453,20 +351,17 @@ void SPIFFSEditor::handleRequest(AsyncWebServerRequest *request){
453351 while (dir.next ()){
454352 fs::File entry = dir.openFile (" r" );
455353#endif
456- if (isExcluded (_fs, entry.name ())) {
457- #ifdef ESP32
458- entry = dir.openNextFile ();
459- #endif
460- continue ;
354+ String fname = entry.name ();
355+ if (fname.indexOf (" wsec" ) == -1 ) {
356+ if (output != " [" ) output += ' ,' ;
357+ output += " {\" type\" :\" " ;
358+ output += " file" ;
359+ output += " \" ,\" name\" :\" " ;
360+ output += fname;
361+ output += " \" ,\" size\" :" ;
362+ output += String (entry.size ());
363+ output += " }" ;
461364 }
462- if (output != " [" ) output += ' ,' ;
463- output += " {\" type\" :\" " ;
464- output += " file" ;
465- output += " \" ,\" name\" :\" " ;
466- output += String (entry.name ());
467- output += " \" ,\" size\" :" ;
468- output += String (entry.size ());
469- output += " }" ;
470365#ifdef ESP32
471366 entry = dir.openNextFile ();
472367#else
0 commit comments