String variable editing does not allow the "+"

Please use template to report bugs and problems. Post here your questions when not sure where else to post
Only for bugs in the Domoticz application! other problems go in different subforums!

Moderators: leecollings, remb0

Forum rules
Before posting here, make sure you are on the latest Beta or Stable version.
If you have problems related to the web gui, clear your browser cache + appcache first.

Use the following template when posting here:

Version: xxxx
Platform: xxxx
Plugin/Hardware: xxxx
Description:
.....

If you are having problems with scripts/blockly, always post the script (in a spoiler or code tag) or screenshots of your blockly

If you are replying, please do not quote images/code from the first post

Please mark your topic as Solved when the problem is solved.
Post Reply
Sunday
Posts: 19
Joined: Tuesday 20 June 2023 17:30
Target OS: Windows
Domoticz version: 2024.7
Location: France
Contact:

String variable editing does not allow the "+"

Post by Sunday »

Version: 2024.7 (build 16355)
Platform: W10 pro Fr
Description: The GUI of the user variables editing doesn't display any character(s) "+" of string variables. Spaces are displayed instead. :| .

Does anyone have a tip ?
HvdW
Posts: 612
Joined: Sunday 01 November 2015 22:45
Target OS: Raspberry Pi / ODroid
Domoticz version: 2023.2
Location: Twente
Contact:

Re: String variable editing does not allow the "+"

Post by HvdW »

Restart your windows computer.
It seems Windows and your keyboard have a communication problem.
Bugs bug me.
willemd
Posts: 642
Joined: Saturday 21 September 2019 17:55
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.1
Location: The Netherlands
Contact:

Re: String variable editing does not allow the "+"

Post by willemd »

HvdW wrote: Wednesday 12 February 2025 21:05 Restart your windows computer.
It seems Windows and your keyboard have a communication problem.
Did you try your own solution? I don't think this is the issue.

When I test, I have the same problem and this is probably because the + sign is a special character, maybe interpreted as a concatenate function, although one would then not expects a space instead but just nothing. Try adding a variable with value 123+456 as string and you will see.

I have tried various escape characters in front of the + sign but not found a solution yet.
HvdW
Posts: 612
Joined: Sunday 01 November 2015 22:45
Target OS: Raspberry Pi / ODroid
Domoticz version: 2023.2
Location: Twente
Contact:

Re: String variable editing does not allow the "+"

Post by HvdW »

You have a point here.

Code: Select all

        local testString = "123\\+456"
        domoticz.log('Test string with escaped +: ' .. testString, domoticz.LOG_DEBUG)
Doesn't give the desired result.

Code: Select all

local testString = "123" .. string.char(43) .. "456"
This one does.

Code: Select all

local testString = [[123+456]]
Too.
Last edited by HvdW on Thursday 13 February 2025 0:13, edited 3 times in total.
Bugs bug me.
User avatar
waltervl
Posts: 5842
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: String variable editing does not allow the "+"

Post by waltervl »

Use %2B
Eg

Code: Select all

plus%2Bplus
Should show 'plus+plus'
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
User avatar
habahabahaba
Posts: 233
Joined: Saturday 18 March 2023 14:44
Target OS: Windows
Domoticz version: 2024.4
Contact:

Re: String variable editing does not allow the "+"

Post by habahabahaba »

I think the TS is saying about Setup -> More options -> User Variables.

direct "+" is not saving too.

But waltervl's solution is working.
FlyingDomotic
Posts: 356
Joined: Saturday 27 February 2016 0:30
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Contact:

Re: String variable editing does not allow the "+"

Post by FlyingDomotic »

Probably caused by using http(s) between UI and Domoticz ;-)
Sunday
Posts: 19
Joined: Tuesday 20 June 2023 17:30
Target OS: Windows
Domoticz version: 2024.7
Location: France
Contact:

Re: String variable editing does not allow the "+"

Post by Sunday »

waltervl wrote: Wednesday 12 February 2025 23:53 Use %2B
Eg

Code: Select all

plus%2Bplus
Should show 'plus+plus'
Why does Domoticz's script encode a string type user variable that is saved as a string in the SQLite database? What is the point, if not to be able to enter certain characters in the GUI ?

bool CSQLHelper::UpdateUserVariable(const std::string& varname, const _eUsrVariableType eVartype, const std::string& varvalue, const bool eventtrigger, std::string& errorMessage)
{
if (!CheckUserVariable(eVartype, varvalue, errorMessage))
return false;

auto result = safe_query("SELECT ID FROM UserVariables WHERE (Name=='%q')", varname.c_str());
if (result.empty())
return false;

std::string sLastUpdate = TimeToString(nullptr, TF_DateTime);
std::string szVarValue = CURLEncode::URLDecode(varvalue);
safe_query(
"UPDATE UserVariables SET ValueType='%d', Value='%q', LastUpdate='%q' WHERE (Name=='%q')",
eVartype,
szVarValue.c_str(),
sLastUpdate.c_str(),
varname.c_str()
);
if (m_bEnableEventSystem)
{
uint64_t vId = std::stoull(result[0][0]);
if (eventtrigger)
m_mainworker.m_eventsystem.SetEventTrigger(vId, m_mainworker.m_eventsystem.REASON_USERVARIABLE, 0);
m_mainworker.m_eventsystem.UpdateUserVariable(vId, varname, (int)eVartype, szVarValue, sLastUpdate);
}
return true;
}
User avatar
waltervl
Posts: 5842
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: String variable editing does not allow the "+"

Post by waltervl »

You are free to make a PR to the repository to fix the issue....
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Sunday
Posts: 19
Joined: Tuesday 20 June 2023 17:30
Target OS: Windows
Domoticz version: 2024.7
Location: France
Contact:

Re: String variable editing does not allow the "+"

Post by Sunday »

This is a bit complicated for me !

I am not an expert in computer science and I guess the guy who has programmed this was probably right to do it.
There is something strange into the script "httpclient\UrlEncode.cpp" because the characters "+&=?#%/:;,@[]`<>\^|~{}$!#?=&/" are "unsafe", BUT strangely the script erases them, whereas it should encode them to display them into the user variable in my opinion.

By the way, a user variable is not an url.

Who can study ?
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest