certtools / intelmq-manager

IntelMQ Manager is a graphical interface to manage configurations for IntelMQ framework.
https://docs.intelmq.org/latest/user/manager/
102 stars 56 forks source link

JSON auto-slash fix certtools/intelmq#1579 #206

Closed e3rd closed 4 years ago

e3rd commented 4 years ago

Doubles all backslashes in the bot dict-like parameters.

In order {"time.source":"\*"} would be treated as an object, we have to translate it to {"time.source":"\\*"} first. In web console, it will appear as {"time.source":"\*"}, whereas in the runtime.conf, it will appear as {"time.source":"\\*"} which is identical to the raw string {"time.source": r"\*"}.

e3rd commented 4 years ago

This PR is just an example. It is not meant to be merged.

File: runtime.conf\saveFormData()

try {
            value = JSON.parse(valueInput.value);               // In order '{"time.source":"\*"}' would be treated as an object,
            // we have to translate it to '{"time.source":"\\*"}' first.
            // In the runtime.conf, it will appear as '{"time.source":"\\*"}'
            // which is identical to the raw string '{"time.source": r"\*"}'.
            value = JSON.parse(valueInput.value.replace(/\\/g,'\\\\'));
        } catch (err) {         } catch (err) {
            value = valueInput.value;               value = valueInput.value;
        }           }