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

Word "&curren" inside a variable or inside a comment is replaced by "¤" character after saving a file on file system #22492

Closed
14 tasks
Phlavio-SPR opened this issue Nov 15, 2024 · 6 comments
Assignees
Labels
bug Type - Confirmated Bug fixed Result - The work on the issue has ended

Comments

@Phlavio-SPR
Copy link

Phlavio-SPR commented Nov 15, 2024

PROBLEM DESCRIPTION

Trying to use an API to get wheather information from "api.open-meteo.com", I've found that current version os Tasmota for ESP32 cant process the word "&curren" on file system. Ater using this word inside any file, on a variable or on a comment, the system itself replaces it to "¤", making it impossible to use that API.

REQUESTED INFORMATION

Make sure your have performed every step and checked the applicable boxes before submitting your issue. Thank you!

  • Read the Contributing Guide and Policy and the Code of Conduct
  • Searched the problem in issues
  • Searched the problem in discussions
  • Searched the problem in the docs
  • Searched the problem in the chat
  • Device used (e.g., Sonoff Basic): _____
  • Tasmota binary firmware version number used: _____
    • Pre-compiled
    • Self-compiled
  • Flashing tools used: _____
  • Provide the output of command: Backlog Template; Module; GPIO 255:
  Configuration output here:

  • If using rules, provide the output of this command: Backlog Rule1; Rule2; Rule3:
  Rules output here:

  • Provide the output of this command: Status 0:
  STATUS 0 output here:

  • Set weblog to 4 and then, when you experience your issue, provide the output of the Console log:
  Console output here:

TO REPRODUCE

Steps to reproduce the behavior:
Just create a file on ESP32 version with a comment or variable containing the word "&curren", saving it and then reading it back.

EXPECTED BEHAVIOUR

A clear and concise description of what you expected to happen.

This problem prevents me to use an API that has the word "&current" on its address. It works fine when the the device is restarted for the first time after saving it, but doesn't work on subsequent booting because the actual address is modified by itselt to ""¤t" afterwards.

It should be same data after saving the file and then reading it back.

SCREENSHOTS

When you do this:

Captura de tela 2024-11-15 131829

After saving the file, you get this:

Captura de tela 2024-11-15 131901

ADDITIONAL CONTEXT

Add any other context about the problem here.

(Please, remember to close the issue when the problem has been addressed)

@sfromis
Copy link
Contributor

sfromis commented Nov 15, 2024

Berry has no problem processing a file including &curren (or other HTML character entities), as such files can be written and read without the issue you see.

Instead, this issue is only about using that simplistic file edit function available in the web UI, which becomes unworkable. This is not really recommended for programming anyway, to instead use a better editor, and uploading files.

If you "insist" on coding via the low grade web UI edit function, you can still use a workaround like this (available all places you use a string):
print('here is a string including &' 'current and again &' 'current')
Not very elegant, but workable.

This implicit concatenation is resolved at compile time, hence no runtime "cost". It is designed for having long string spanning multiple lines, but work on one line too.

@Phlavio-SPR
Copy link
Author

@sfromis Thank you for a lighting fast reply.
Both options solve the problems I was facing.
Since there is something not quite well with low grade web UI, should I close this issue for now?

@sfromis
Copy link
Contributor

sfromis commented Nov 15, 2024

While you can work around it, I'd still say that it is a detail worthy of fixing, as the UfsEditor function of xdrv_50_filesystem.ino is not doing any escaping. This can also hit code including textarea tags.

Maybe the HtmlEscape function from support.ino could be used here too. It is already used elsewhere in xdrv_50_filesystem.ino, but not for the edit function.

@s-hadinger
Copy link
Collaborator

I thought we fixed the lack of html escaping a while ago. Worth revisiting what we missed

@sfromis
Copy link
Contributor

sfromis commented Nov 17, 2024

An example of where it breaks at a </textarea> tag:
https://github.com/Staars/berry-examples/blob/main/bleKeyLegacy.be#L394
image

@arendst arendst self-assigned this Nov 21, 2024
@arendst arendst added bug Type - Confirmated Bug fixed Result - The work on the issue has ended labels Nov 21, 2024
@sfromis
Copy link
Contributor

sfromis commented Nov 21, 2024

Works better now, for both types.

@arendst arendst closed this as completed Nov 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Type - Confirmated Bug fixed Result - The work on the issue has ended
Projects
None yet
Development

No branches or pull requests

4 participants