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

SPIFFS with template lost original data #500

Closed
gayratv opened this issue Apr 5, 2019 · 3 comments
Closed

SPIFFS with template lost original data #500

gayratv opened this issue Apr 5, 2019 · 3 comments
Labels

Comments

@gayratv
Copy link

gayratv commented Apr 5, 2019

I'm use responce from file in SPIFFS with template:

String processor_config(const String& var)
{
 if (var == ("tick1_ON") )
      return String (5);
 .....
  return String();
}
void handle_Config(AsyncWebServerRequest *request) {
    request->send(SPIFFS, "/config2.htm", "text/html", false, processor_config);
};

The problem :
Original file (config2.htm) consist following CSS classes:
body,h1,.form , .item1, .label1 and others

But after processing this file with templates class defeneition ".label1" was removed from output stream (and some others class also removed)

But if I'm use simple SPIFFS answer, original file was transferred without any changes

void handle_Config2(AsyncWebServerRequest *request) {
    request->send(SPIFFS, "/config2.htm");
};

I'm provide small platformio project for Esp8266 with 4mb flash with this issue
Spiffs Issue.zip

@boarchuz
Copy link

boarchuz commented Apr 7, 2019

I happened to be checking here because I just noticed the same problem, and this is the top issue!
Your problem is the same as mine: You have a '%' in your string to be processed that is NOT part of a template.
The quick fix would be to create a template for the % character. For example, your css for .item1 might become:

.item1 {
            width: 100%PERCENT_SYMBOL%;
            margin: 5px;
            display: flex;
            flex-direction: row;
            justify-content: flex-end;
            flex-wrap: wrap;
        }

with a corresponding entry in your processor to return "%" for "PERCENT_SYMBOL".

The better solution would probably be for AWS to use a more obscure character for templates since % is fairly common, and/or allow the user to send a custom one that they know won't have any conflicts.

Edit: Scratch all that^

The 'quick fix' doesn't work because the template processor will try to process the % it just substituted.
Thankfully there's a proper fix already though (You can define your own TEMPLATE_PLACEHOLDER): #366

@stale
Copy link

stale bot commented Sep 21, 2019

[STALE_SET] This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 14 days if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Sep 21, 2019
@stale
Copy link

stale bot commented Oct 5, 2019

[STALE_DEL] This stale issue has been automatically closed. Thank you for your contributions.

@stale stale bot closed this as completed Oct 5, 2019
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

2 participants