diff options
author | joaodasilva@chromium.org <joaodasilva@chromium.org> | 2014-11-05 11:12:28 +0000 |
---|---|---|
committer | joaodasilva@chromium.org <joaodasilva@chromium.org> | 2014-11-05 11:12:28 +0000 |
commit | a24a0e647bb718b3540db89864cf586b12331e82 (patch) | |
tree | 9a7b625bfe5d41bda8cb037eb7380ed8a72f8fba | |
parent | ed56c5085093f0ae35e2751c1da8aa14e9dabc97 (diff) | |
download | grit-a24a0e647bb718b3540db89864cf586b12331e82.tar.gz |
Set the MAXLEN/maxLength attribute for strings in ADM[X] templates.
This allows strings and JSON blobs in the registry and GPO
objects to have a length longer than the default of 1023 characters.
BUG=chromium:428340
Review URL: https://codereview.chromium.org/687073003
git-svn-id: http://grit-i18n.googlecode.com/svn/trunk@182 7262f16d-afe8-6277-6482-052fa10e57b1
5 files changed, 15 insertions, 4 deletions
diff --git a/grit/format/policy_templates/writers/adm_writer.py b/grit/format/policy_templates/writers/adm_writer.py index 7ab612c..91aeef6 100644 --- a/grit/format/policy_templates/writers/adm_writer.py +++ b/grit/format/policy_templates/writers/adm_writer.py @@ -122,6 +122,10 @@ class AdmWriter(template_writer.TemplateWriter): if policy['type'] == 'int': # The default max for NUMERIC values is 9999 which is too small for us. builder.AddLine('MIN 0 MAX 2000000000') + if policy['type'] in ('string', 'dict'): + # The default max for EDITTEXT values is 1023, which is too small for + # big JSON blobs and other string policies. + builder.AddLine('MAXLEN 1000000') if policy['type'] in ('int-enum', 'string-enum'): builder.AddLine('ITEMLIST', 1) for item in policy['items']: diff --git a/grit/format/policy_templates/writers/adm_writer_unittest.py b/grit/format/policy_templates/writers/adm_writer_unittest.py index b126391..c5c64f7 100644 --- a/grit/format/policy_templates/writers/adm_writer_unittest.py +++ b/grit/format/policy_templates/writers/adm_writer_unittest.py @@ -286,6 +286,7 @@ With a newline.""", PART !!StringPolicy_Part EDITTEXT VALUENAME "StringPolicy" + MAXLEN 1000000 END PART END POLICY @@ -302,6 +303,7 @@ With a newline.""", PART !!StringPolicy_Part EDITTEXT VALUENAME "StringPolicy" + MAXLEN 1000000 END PART END POLICY @@ -770,6 +772,7 @@ ListPolicy_Part="Label of list policy." PART !!DictionaryPolicy_Part EDITTEXT VALUENAME "DictionaryPolicy" + MAXLEN 1000000 END PART END POLICY @@ -786,6 +789,7 @@ ListPolicy_Part="Label of list policy." PART !!DictionaryPolicy_Part EDITTEXT VALUENAME "DictionaryPolicy" + MAXLEN 1000000 END PART END POLICY @@ -978,6 +982,7 @@ With a newline.""" PART !!Policy2_Part EDITTEXT VALUENAME "Policy2" + MAXLEN 1000000 END PART END POLICY diff --git a/grit/format/policy_templates/writers/admx_writer.py b/grit/format/policy_templates/writers/admx_writer.py index 4bfb723..d657834 100644 --- a/grit/format/policy_templates/writers/admx_writer.py +++ b/grit/format/policy_templates/writers/admx_writer.py @@ -168,6 +168,7 @@ class ADMXWriter(xml_formatted_writer.XMLFormattedWriter): attributes = { 'id': name, 'valueName': name, + 'maxLength': '1000000', } self.AddElement(parent, 'text', attributes) diff --git a/grit/format/policy_templates/writers/admx_writer_unittest.py b/grit/format/policy_templates/writers/admx_writer_unittest.py index 493c715..8bdb7a4 100644 --- a/grit/format/policy_templates/writers/admx_writer_unittest.py +++ b/grit/format/policy_templates/writers/admx_writer_unittest.py @@ -309,7 +309,8 @@ class AdmxWriterUnittest(xml_writer_base_unittest.XmlWriterBaseTest): ' <parentCategory ref="PolicyGroup"/>\n' ' <supportedOn ref="SUPPORTED_TESTOS"/>\n' ' <elements>\n' - ' <text id="SampleStringPolicy" valueName="SampleStringPolicy"/>\n' + ' <text id="SampleStringPolicy" maxLength="1000000"' + ' valueName="SampleStringPolicy"/>\n' ' </elements>\n' '</policy>') self.AssertXMLEquals(output, expected_output) @@ -487,8 +488,8 @@ class AdmxWriterUnittest(xml_writer_base_unittest.XmlWriterBaseTest): ' <parentCategory ref="PolicyGroup"/>\n' ' <supportedOn ref="SUPPORTED_TESTOS"/>\n' ' <elements>\n' - ' <text id="SampleDictionaryPolicy" ' - 'valueName="SampleDictionaryPolicy"/>\n' + ' <text id="SampleDictionaryPolicy" maxLength="1000000"' + ' valueName="SampleDictionaryPolicy"/>\n' ' </elements>\n' '</policy>') self.AssertXMLEquals(output, expected_output) diff --git a/grit/format/policy_templates/writers/xml_formatted_writer.py b/grit/format/policy_templates/writers/xml_formatted_writer.py index dad3717..5917fb4 100644 --- a/grit/format/policy_templates/writers/xml_formatted_writer.py +++ b/grit/format/policy_templates/writers/xml_formatted_writer.py @@ -31,7 +31,7 @@ class XMLFormattedWriter(template_writer.TemplateWriter): doc = parent.ownerDocument element = doc.createElement(name) - for key, value in attrs.iteritems(): + for key, value in sorted(attrs.iteritems()): element.setAttribute(key, value) if text: element.appendChild(doc.createTextNode(text)) |