Skip to content

Commit 3746524

Browse files
magento#14882: improve regular expression
1 parent 9948dfe commit 3746524

File tree

9 files changed

+20
-20
lines changed

9 files changed

+20
-20
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
'</option></config>',
3434
[
3535
"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",
36+
"pattern '([\\\\]?[a-zA-Z_][a-zA-Z0-9_]*)+'.\nLine: 1\n",
3737
"Element 'option', attribute 'renderer': '123true' is not a valid value of the atomic" .
3838
" type 'modelName'.\nLine: 1\n"
3939
],

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_\\\\]+[a-zA-Z0-9_\\\\]+'.\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_\\\\]+[a-zA-Z0-9_\\\\]+'.\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_\\\\]+[a-zA-Z0-9_\\\\]+'.\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_\\\\]+[a-zA-Z0-9_\\\\]+'.\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/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_\\]+[a-zA-Z0-9_\\]+.
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_\\]+[a-zA-Z0-9_\\]+" />
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_\\]+[a-zA-Z0-9_\\]+.
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_\\]+[a-zA-Z0-9_\\]+" />
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: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@
2525
. ' <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_\\\\]+[a-zA-Z0-9_\\\\]+'.\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",
3131
"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",
32+
"accepted by the pattern '([\\\\]?[a-zA-Z_][a-zA-Z0-9_]*)+'.\nLine: 1\n",
3333
"Element 'fileFormat', attribute 'model': '1model' is not a valid " .
3434
"value of the atomic type 'modelName'.\nLine: 1\n"
3535
],

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
'behaviorModel="test" /></config>',
3131
[
3232
"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",
33+
"accepted by the pattern '([\\\\]?[a-zA-Z_][a-zA-Z0-9_]*)+'.\nLine: 1\n",
3434
"Element 'entity', attribute 'model': '34afwer' is not a valid value of the atomic type" .
3535
" 'modelName'.\nLine: 1\n"
3636
],
@@ -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_\\\\]+[a-zA-Z0-9_\\\\]+'.\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: 3 additions & 3 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_\\\\]+[a-zA-Z0-9_\\\\]+'.\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_\\\\]+[a-zA-Z0-9_\\\\]+'.\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
],
@@ -49,7 +49,7 @@
4949
'<?xml version="1.0"?><config><entityType entity="entity_name" name="some_name" model="1test"/></config>',
5050
[
5151
"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",
52+
"accepted by the pattern '([\\\\]?[a-zA-Z_][a-zA-Z0-9_]*)+'.\nLine: 1\n",
5353
"Element 'entityType', attribute 'model': '1test' is not a valid value of the atomic type" .
5454
" 'modelName'.\nLine: 1\n"
5555
],

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_\\]+[a-zA-Z0-9_\\]+.
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_\\]+[a-zA-Z0-9_\\]+" />
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_\\]+[a-zA-Z0-9_\\]+.
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_\\]+[a-zA-Z0-9_\\]+" />
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)