Skip to content

Commit 86414f6

Browse files
ENGCOM-4065: 14882 product types xml doesn t allow numbers in model instance #20617
- Merge Pull Request #20617 from lisovyievhenii/magento2:14882-product-types-xml-doesn-t-allow-numbers-in-modelInstance - Merged commits: 1. eb0653c 2. 9948dfe 3. 3746524
2 parents 4f23251 + 3746524 commit 86414f6

File tree

10 files changed

+41
-32
lines changed

10 files changed

+41
-32
lines changed

app/code/Magento/Catalog/Test/Unit/Model/ProductOptions/Config/_files/invalidProductOptionsXmlArray.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,12 @@
2929
],
3030
],
3131
'renderer_attribute_with_invalid_value' => [
32-
'<?xml version="1.0"?><config><option name="name_one" renderer="true12"><inputType name="name_one"/>' .
32+
'<?xml version="1.0"?><config><option name="name_one" renderer="123true"><inputType name="name_one"/>' .
3333
'</option></config>',
3434
[
35-
"Element 'option', attribute 'renderer': [facet 'pattern'] The value 'true12' is not accepted by the " .
36-
"pattern '[a-zA-Z_\\\\]+'.\nLine: 1\n",
37-
"Element 'option', attribute 'renderer': 'true12' is not a valid value of the atomic" .
35+
"Element 'option', attribute 'renderer': [facet 'pattern'] The value '123true' is not accepted by the " .
36+
"pattern '([\\\\]?[a-zA-Z_][a-zA-Z0-9_]*)+'.\nLine: 1\n",
37+
"Element 'option', attribute 'renderer': '123true' is not a valid value of the atomic" .
3838
" type 'modelName'.\nLine: 1\n"
3939
],
4040
],

app/code/Magento/Catalog/Test/Unit/Model/ProductTypes/Config/_files/invalidProductTypesXmlArray.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
'<?xml version="1.0"?><config><type name="some_name" modelInstance="123" /></config>',
2424
[
2525
"Element 'type', attribute 'modelInstance': [facet 'pattern'] The value '123' is not accepted by the" .
26-
" pattern '[a-zA-Z_\\\\]+'.\nLine: 1\n",
26+
" pattern '([\\\\]?[a-zA-Z_][a-zA-Z0-9_]*)+'.\nLine: 1\n",
2727
"Element 'type', attribute 'modelInstance': '123' is not a valid value of the atomic type" .
2828
" 'modelName'.\nLine: 1\n"
2929
],
@@ -57,7 +57,7 @@
5757
'<?xml version="1.0"?><config><type name="some_name"><priceModel instance="123123" /></type></config>',
5858
[
5959
"Element 'priceModel', attribute 'instance': [facet 'pattern'] The value '123123' is not accepted " .
60-
"by the pattern '[a-zA-Z_\\\\]+'.\nLine: 1\n",
60+
"by the pattern '([\\\\]?[a-zA-Z_][a-zA-Z0-9_]*)+'.\nLine: 1\n",
6161
"Element 'priceModel', attribute 'instance': '123123' is not a valid value of the atomic type" .
6262
" 'modelName'.\nLine: 1\n"
6363
],
@@ -66,7 +66,7 @@
6666
'<?xml version="1.0"?><config><type name="some_name"><indexerModel instance="123" /></type></config>',
6767
[
6868
"Element 'indexerModel', attribute 'instance': [facet 'pattern'] The value '123' is not accepted by " .
69-
"the pattern '[a-zA-Z_\\\\]+'.\nLine: 1\n",
69+
"the pattern '([\\\\]?[a-zA-Z_][a-zA-Z0-9_]*)+'.\nLine: 1\n",
7070
"Element 'indexerModel', attribute 'instance': '123' is not a valid value of the atomic type" .
7171
" 'modelName'.\nLine: 1\n"
7272
],
@@ -83,7 +83,7 @@
8383
'<?xml version="1.0"?><config><type name="some_name"><stockIndexerModel instance="1234"/></type></config>',
8484
[
8585
"Element 'stockIndexerModel', attribute 'instance': [facet 'pattern'] The value '1234' is not " .
86-
"accepted by the pattern '[a-zA-Z_\\\\]+'.\nLine: 1\n",
86+
"accepted by the pattern '([\\\\]?[a-zA-Z_][a-zA-Z0-9_]*)+'.\nLine: 1\n",
8787
"Element 'stockIndexerModel', attribute 'instance': '1234' is not a valid value of the atomic " .
8888
"type 'modelName'.\nLine: 1\n"
8989
],

app/code/Magento/Catalog/Test/Unit/Model/ProductTypes/Config/_files/valid_product_types_merged.xml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,14 @@
1515
<stockIndexerModel instance="instance_name"/>
1616
</type>
1717
<type label="some_label" name="some_name2" modelInstance="model_name">
18+
<allowedSelectionTypes>
19+
<type name="some_name" />
20+
</allowedSelectionTypes>
21+
<priceModel instance="instance_name_with_digits_123" />
22+
<indexerModel instance="instance_name_with_digits_123" />
23+
<stockIndexerModel instance="instance_name_with_digits_123"/>
24+
</type>
25+
<type label="some_label" name="some_name3" modelInstance="model_name">
1826
<allowedSelectionTypes>
1927
<type name="some_name" />
2028
</allowedSelectionTypes>
@@ -25,5 +33,6 @@
2533
<composableTypes>
2634
<type name="some_name"/>
2735
<type name="some_name2"/>
36+
<type name="some_name3"/>
2837
</composableTypes>
2938
</config>

app/code/Magento/Catalog/etc/product_options.xsd

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,11 @@
6161
<xs:simpleType name="modelName">
6262
<xs:annotation>
6363
<xs:documentation>
64-
Model name can contain only [a-zA-Z_\\].
64+
Model name can contain only ([\\]?[a-zA-Z_][a-zA-Z0-9_]*)+.
6565
</xs:documentation>
6666
</xs:annotation>
6767
<xs:restriction base="xs:string">
68-
<xs:pattern value="[a-zA-Z_\\]+" />
68+
<xs:pattern value="([\\]?[a-zA-Z_][a-zA-Z0-9_]*)+" />
6969
</xs:restriction>
7070
</xs:simpleType>
7171
</xs:schema>

app/code/Magento/Catalog/etc/product_types_base.xsd

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,11 @@
9292
<xs:simpleType name="modelName">
9393
<xs:annotation>
9494
<xs:documentation>
95-
Model name can contain only [a-zA-Z_\\].
95+
Model name can contain only ([\\]?[a-zA-Z_][a-zA-Z0-9_]*)+.
9696
</xs:documentation>
9797
</xs:annotation>
9898
<xs:restriction base="xs:string">
99-
<xs:pattern value="[a-zA-Z_\\]+" />
99+
<xs:pattern value="([\\]?[a-zA-Z_][a-zA-Z0-9_]*)+" />
100100
</xs:restriction>
101101
</xs:simpleType>
102102
</xs:schema>

app/code/Magento/ImportExport/Test/Unit/Model/Export/Config/_files/invalidExportXmlArray.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,15 @@
2222
'attributes_with_type_modelName_and_invalid_value' => [
2323
'<?xml version="1.0"?><config><entity name="Name/one" model="model_one" '
2424
. 'entityAttributeFilterType="model_one"/><entityType entity="Name/one" name="name_one" model="1"/>'
25-
. ' <fileFormat name="name_one" model="model1"/></config>',
25+
. ' <fileFormat name="name_one" model="1model"/></config>',
2626
[
2727
"Element 'entityType', attribute 'model': [facet 'pattern'] The value '1' is not accepted by the " .
28-
"pattern '[A-Za-z_\\\\]+'.\nLine: 1\n",
28+
"pattern '([\\\\]?[a-zA-Z_][a-zA-Z0-9_]*)+'.\nLine: 1\n",
2929
"Element 'entityType', attribute 'model': '1' is not a valid value of the atomic type" .
3030
" 'modelName'.\nLine: 1\n",
31-
"Element 'fileFormat', attribute 'model': [facet 'pattern'] The value 'model1' is not " .
32-
"accepted by the pattern '[A-Za-z_\\\\]+'.\nLine: 1\n",
33-
"Element 'fileFormat', attribute 'model': 'model1' is not a valid " .
31+
"Element 'fileFormat', attribute 'model': [facet 'pattern'] The value '1model' is not " .
32+
"accepted by the pattern '([\\\\]?[a-zA-Z_][a-zA-Z0-9_]*)+'.\nLine: 1\n",
33+
"Element 'fileFormat', attribute 'model': '1model' is not a valid " .
3434
"value of the atomic type 'modelName'.\nLine: 1\n"
3535
],
3636
],

app/code/Magento/ImportExport/Test/Unit/Model/Import/Config/_files/invalidImportMergedXmlArray.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@
2626
["Element 'entity', attribute 'notallowed': The attribute 'notallowed' is not allowed.\nLine: 1\n"],
2727
],
2828
'entity_model_with_invalid_value' => [
29-
'<?xml version="1.0"?><config><entity name="test_name" label="test_label" model="afwer34" ' .
29+
'<?xml version="1.0"?><config><entity name="test_name" label="test_label" model="34afwer" ' .
3030
'behaviorModel="test" /></config>',
3131
[
32-
"Element 'entity', attribute 'model': [facet 'pattern'] The value 'afwer34' is not " .
33-
"accepted by the pattern '[A-Za-z_\\\\]+'.\nLine: 1\n",
34-
"Element 'entity', attribute 'model': 'afwer34' is not a valid value of the atomic type" .
32+
"Element 'entity', attribute 'model': [facet 'pattern'] The value '34afwer' is not " .
33+
"accepted by the pattern '([\\\\]?[a-zA-Z_][a-zA-Z0-9_]*)+'.\nLine: 1\n",
34+
"Element 'entity', attribute 'model': '34afwer' is not a valid value of the atomic type" .
3535
" 'modelName'.\nLine: 1\n"
3636
],
3737
],
@@ -40,7 +40,7 @@
4040
'</config>',
4141
[
4242
"Element 'entity', attribute 'behaviorModel': [facet 'pattern'] The value '666' is not accepted by " .
43-
"the pattern '[A-Za-z_\\\\]+'.\nLine: 1\n",
43+
"the pattern '([\\\\]?[a-zA-Z_][a-zA-Z0-9_]*)+'.\nLine: 1\n",
4444
"Element 'entity', attribute 'behaviorModel': '666' is not a valid value of the atomic type" .
4545
" 'modelName'.\nLine: 1\n"
4646
],

app/code/Magento/ImportExport/Test/Unit/Model/Import/Config/_files/invalidImportXmlArray.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
'<?xml version="1.0"?><config><entity name="some_name" model="12345"/></config>',
2020
[
2121
"Element 'entity', attribute 'model': [facet 'pattern'] The value '12345' is not accepted by " .
22-
"the pattern '[A-Za-z_\\\\]+'.\nLine: 1\n",
22+
"the pattern '([\\\\]?[a-zA-Z_][a-zA-Z0-9_]*)+'.\nLine: 1\n",
2323
"Element 'entity', attribute 'model': '12345' is not a valid value of the atomic type" .
2424
" 'modelName'.\nLine: 1\n"
2525
],
@@ -28,7 +28,7 @@
2828
'<?xml version="1.0"?><config><entity name="some_name" behaviorModel="=--09"/></config>',
2929
[
3030
"Element 'entity', attribute 'behaviorModel': [facet 'pattern'] The value '=--09' is not " .
31-
"accepted by the pattern '[A-Za-z_\\\\]+'.\nLine: 1\n",
31+
"accepted by the pattern '([\\\\]?[a-zA-Z_][a-zA-Z0-9_]*)+'.\nLine: 1\n",
3232
"Element 'entity', attribute 'behaviorModel': '=--09' is not a valid value of the atomic type" .
3333
" 'modelName'.\nLine: 1\n"
3434
],
@@ -46,11 +46,11 @@
4646
["Element 'entityType': The attribute 'model' is required but missing.\nLine: 1\n"],
4747
],
4848
'entitytype_with_invalid_model_attribute_value' => [
49-
'<?xml version="1.0"?><config><entityType entity="entity_name" name="some_name" model="test1"/></config>',
49+
'<?xml version="1.0"?><config><entityType entity="entity_name" name="some_name" model="1test"/></config>',
5050
[
51-
"Element 'entityType', attribute 'model': [facet 'pattern'] The value 'test1' is not " .
52-
"accepted by the pattern '[A-Za-z_\\\\]+'.\nLine: 1\n",
53-
"Element 'entityType', attribute 'model': 'test1' is not a valid value of the atomic type" .
51+
"Element 'entityType', attribute 'model': [facet 'pattern'] The value '1test' is not " .
52+
"accepted by the pattern '([\\\\]?[a-zA-Z_][a-zA-Z0-9_]*)+'.\nLine: 1\n",
53+
"Element 'entityType', attribute 'model': '1test' is not a valid value of the atomic type" .
5454
" 'modelName'.\nLine: 1\n"
5555
],
5656
],

app/code/Magento/ImportExport/etc/export.xsd

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,11 @@
7171
<xs:simpleType name="modelName">
7272
<xs:annotation>
7373
<xs:documentation>
74-
Model name can contain only [A-Za-z_\\].
74+
Model name can contain only ([\\]?[a-zA-Z_][a-zA-Z0-9_]*)+.
7575
</xs:documentation>
7676
</xs:annotation>
7777
<xs:restriction base="xs:string">
78-
<xs:pattern value="[A-Za-z_\\]+" />
78+
<xs:pattern value="([\\]?[a-zA-Z_][a-zA-Z0-9_]*)+" />
7979
</xs:restriction>
8080
</xs:simpleType>
8181
</xs:schema>

app/code/Magento/ImportExport/etc/import.xsd

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,11 @@
6161
<xs:simpleType name="modelName">
6262
<xs:annotation>
6363
<xs:documentation>
64-
Model name can contain only [A-Za-z_\\].
64+
Model name can contain only ([\\]?[a-zA-Z_][a-zA-Z0-9_]*)+.
6565
</xs:documentation>
6666
</xs:annotation>
6767
<xs:restriction base="xs:string">
68-
<xs:pattern value="[A-Za-z_\\]+" />
68+
<xs:pattern value="([\\]?[a-zA-Z_][a-zA-Z0-9_]*)+" />
6969
</xs:restriction>
7070
</xs:simpleType>
7171
</xs:schema>

0 commit comments

Comments
 (0)