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

Values with double quotes in text areas not working properly #102

Closed
abaskin opened this issue Feb 11, 2019 · 8 comments
Closed

Values with double quotes in text areas not working properly #102

abaskin opened this issue Feb 11, 2019 · 8 comments
Assignees

Comments

@abaskin
Copy link

abaskin commented Feb 11, 2019

When I enter a value that includes double quotes into a text area field, the value is accepted and saved properly. However when I later enter configuration mode and select the setting tab the resulting page is blank. An example value is below. I see the same result for both one line and multi line values that include double quotes.

{ "name": "Test Module 1", "switch": [{ "name": "Test Switch 1", "pin": "D1", "led": ["D4"] }] }

@Onno-Dirkzwager
Copy link
Collaborator

Onno-Dirkzwager commented Feb 11, 2019

Hi @abaskin,
just to be sure:
This is the entire value you are trying to store

{ "name": "Test Module 1", "switch": [{ "name": "Test Switch 1", "pin": "D1", "led": ["D4"] }] }

into a textarea.

If so. Aside from the posible " bug. Why not save these as separate fields?

  • name
  • pin
  • led
    You would be able to use the pin field type as well.

@abaskin
Copy link
Author

abaskin commented Feb 11, 2019

Yes, this is the entire value I am trying to store. The reason for using JSON as opposed to individual fields is that the app supports a number of different things attached to the device. So one device may have a DHT sensor attached and another may have a switch, relay and led attached. Supporting each attached thing with separate fields would make the setup page unwieldy at best especially for something like LED's where there may be more than one attached to the device.

@Onno-Dirkzwager
Copy link
Collaborator

Onno-Dirkzwager commented Feb 11, 2019

@abaskin
I see.
We will dive into the code. I think we should add js script that escapes the quotes with backslashes before sending the string to your esp for saving.

Maby you can help by testing if this works by just hardcoding this value into a var without using the IAS addfield stuff? Storing should not be the problem. Im wondering if the json still gets read correctly when taken from this var.

@Onno-Dirkzwager Onno-Dirkzwager self-assigned this Feb 11, 2019
@Onno-Dirkzwager
Copy link
Collaborator

Onno-Dirkzwager commented Mar 1, 2019

@abaskin FIXED!
It turns out saving your values was not the problem. But it did break the json format that gets sent to your browser when running the config pages. So after trying to do the usual backslahes we decided to urlencode the quotes in the value before sending it to the browser. Js scripts in the config pages handel decoding.

Example:
[
{
"l":"Textarea",
"v":"{ %22name%22: %22Test Module 1%22, %22switch%22: [{ %22name%22: %22Test Switch 1%22, %22pin%22: %22D1%22, %22led%22: [%22D4%22] }] }",
"n":"1",
"m":"121",
"t":"T"
}
]

Changes were made here: c42ab03

We need a few people to test this before we can send out a new release. Maby you can help?

Easiest thing would be te replace your IOTAppStory.h and .cpp files with the changed ones from the master.

@Onno-Dirkzwager
Copy link
Collaborator

@Onno-Dirkzwager
Copy link
Collaborator

Added a new release: https://github.com/iotappstory/ESP-Library/releases/latest

Should be in the library manager within an hour.

@Onno-Dirkzwager
Copy link
Collaborator

@abaskin I think we can close this issue do you agree?

@abaskin
Copy link
Author

abaskin commented Mar 5, 2019

Yes

@abaskin abaskin closed this as completed Mar 5, 2019
Onno-Dirkzwager added a commit that referenced this issue Mar 13, 2019
- Implemented changes made in the master for issue #102
- Moved the ESP32 PROGMEM root ca to src\espressif\esp32\callServer_WiFiClientSecure.h (root ca is optional as the new default is to store it in SPIFFS which can be updated)
- Moved the ESP8266 default fingerprint to config.h as a define
- Added strCertScan method. Which scans SPIFFS folder /certs/ for certificates
Onno-Dirkzwager added a commit that referenced this issue Mar 13, 2019
- Updated defines accourding to: iotappstory/ESP-Library/commit/59aa54d17438bc28276ad197db88d346cadd95f7
- ESP32: getFreeSketchSpace(), getSketchSize() & ESP_GETCHIPID are available since the latest core release. So use them...
- Implemented changes made in the master for issue #102
- Added strCertScan method. Which scans SPIFFS folder /certs/ for certificates
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants