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

Escape XML values #2

Draft
wants to merge 18 commits into
base: 0.24.1
Choose a base branch
from
3 changes: 2 additions & 1 deletion pkg/xml/xml.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
package xml

import (
"encoding/xml"
"fmt"
"io"
"regexp"
Expand Down Expand Up @@ -254,5 +255,5 @@ func (n *xmlNode) writeTag(w io.Writer, indent uint8, attributes string, openTag

// writeValue prints XML value into io.Writer
func (n *xmlNode) writeValue(w io.Writer, value string) {
util.Fprintf(w, "%s", value)
_ = xml.EscapeText(w, []byte(value))
}
4 changes: 2 additions & 2 deletions tests/e2e/clickhouse.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import shlex
import e2e.kubectl as kubectl
import e2e.settings as settings
from testflows.core import *


def query(
chi_name,
sql,
Expand All @@ -24,7 +24,7 @@ def query(
pod_name = p
break

pwd_str = "" if pwd == "" else f"--password={pwd}"
pwd_str = "" if pwd == "" else shlex.quote(f"--password={pwd}")
user_str = "" if user == "" else f"--user={user}"

if with_error:
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/manifests/chi/test-016-settings-02.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ spec:
users:
user2/profile: default
user2/quota: default
user2/password: qwerty
user2/password: needs<Xml&escaping # test for xml-special characters
user2/networks/ip: "::/0"
settings:
dictionaries_config: config.d/dict_*.xml
Expand Down
4 changes: 2 additions & 2 deletions tests/e2e/test_operator.py
Original file line number Diff line number Diff line change
Expand Up @@ -1821,7 +1821,7 @@ def test_016(self):
version_user1 = clickhouse.query_with_error(chi, sql="select version()", user="user1", pwd="qwerty")
assert version != version_user1
with And("user2 user should be available"):
version_user2 = clickhouse.query(chi, sql="select version()", user="user2", pwd="qwerty")
version_user2 = clickhouse.query(chi, sql="select version()", user="user2", pwd="needs<Xml&escaping")
assert version == version_user2
with And("ClickHouse SHOULD NOT be restarted"):
new_start_time = kubectl.get_field("pod", f"chi-{chi}-default-0-0-0", ".status.startTime")
Expand Down Expand Up @@ -1902,7 +1902,7 @@ def test_016(self):
assert out == "test-changed"

# test-016-settings-06.yaml
with When("Add I change a number of settings that does not requre a restart"):
with When("Add I change a number of settings that does not require a restart"):
start_time = kubectl.get_field("pod", f"chi-{chi}-default-0-0-0", ".status.startTime")
kubectl.create_and_check(
manifest="manifests/chi/test-016-settings-06.yaml",
Expand Down
Loading