forked from brentwpeterson/magento-patches
-
Notifications
You must be signed in to change notification settings - Fork 0
/
PATCH_SUPEE-11155_CE_1.7.0.2_v3-2019-06-18-08-07-47.patch
2435 lines (2391 loc) · 112 KB
/
PATCH_SUPEE-11155_CE_1.7.0.2_v3-2019-06-18-08-07-47.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
diff --git app/Mage.php app/Mage.php
index a7e96df68be..eb3eb5e63c2 100644
--- app/Mage.php
+++ app/Mage.php
@@ -812,9 +812,9 @@ final class Mage
',',
(string) self::getConfig()->getNode('dev/log/allowedFileExtensions', Mage_Core_Model_Store::DEFAULT_CODE)
);
- $logValidator = new Zend_Validate_File_Extension($_allowedFileExtensions);
$logDir = self::getBaseDir('var') . DS . 'log';
- if (!$logValidator->isValid($logDir . DS . $file)) {
+ $validatedFileExtension = pathinfo($file, PATHINFO_EXTENSION);
+ if (!$validatedFileExtension || !in_array($validatedFileExtension, $_allowedFileExtensions)) {
return;
}
diff --git app/code/core/Mage/Admin/Model/Block.php app/code/core/Mage/Admin/Model/Block.php
index a672f4ef350..61c6134964d 100644
--- app/code/core/Mage/Admin/Model/Block.php
+++ app/code/core/Mage/Admin/Model/Block.php
@@ -57,7 +57,7 @@ class Mage_Admin_Model_Block extends Mage_Core_Model_Abstract
if (in_array($this->getBlockName(), $disallowedBlockNames)) {
$errors[] = Mage::helper('adminhtml')->__('Block Name is disallowed.');
}
- if (!Zend_Validate::is($this->getBlockName(), 'Regex', array('/^[-_a-zA-Z0-9\/]*$/'))) {
+ if (!Zend_Validate::is($this->getBlockName(), 'Regex', array('/^[-_a-zA-Z0-9]+\/[-_a-zA-Z0-9\/]+$/'))) {
$errors[] = Mage::helper('adminhtml')->__('Block Name is incorrect.');
}
diff --git app/code/core/Mage/Admin/Model/User.php app/code/core/Mage/Admin/Model/User.php
index e5049b71e37..2dca27d10cd 100644
--- app/code/core/Mage/Admin/Model/User.php
+++ app/code/core/Mage/Admin/Model/User.php
@@ -567,7 +567,7 @@ class Mage_Admin_Model_User extends Mage_Core_Model_Abstract
}
if ($this->userExists()) {
- $errors[] = Mage::helper('adminhtml')->__('A user with the same user name or email aleady exists.');
+ $errors[] = Mage::helper('adminhtml')->__('A user with the same user name or email already exists.');
}
if (count($errors) === 0) {
diff --git app/code/core/Mage/AdminNotification/etc/system.xml app/code/core/Mage/AdminNotification/etc/system.xml
index fe6b6cd8384..8703a65d981 100644
--- app/code/core/Mage/AdminNotification/etc/system.xml
+++ app/code/core/Mage/AdminNotification/etc/system.xml
@@ -64,6 +64,15 @@
<show_in_website>0</show_in_website>
<show_in_store>0</show_in_store>
</last_update>
+ <feed_url>
+ <label>Feed Url</label>
+ <frontend_type>text</frontend_type>
+ <backend_model>adminhtml/system_config_backend_protected</backend_model>
+ <sort_order>3</sort_order>
+ <show_in_default>0</show_in_default>
+ <show_in_website>0</show_in_website>
+ <show_in_store>0</show_in_store>
+ </feed_url>
</fields>
</adminnotification>
</groups>
diff --git app/code/core/Mage/Adminhtml/Block/Api/Role/Grid/User.php app/code/core/Mage/Adminhtml/Block/Api/Role/Grid/User.php
index d6355a6b30b..a96a05d7d0e 100644
--- app/code/core/Mage/Adminhtml/Block/Api/Role/Grid/User.php
+++ app/code/core/Mage/Adminhtml/Block/Api/Role/Grid/User.php
@@ -157,7 +157,7 @@ class Mage_Adminhtml_Block_Api_Role_Grid_User extends Mage_Adminhtml_Block_Widge
protected function _getUsers($json=false)
{
if ( $this->getRequest()->getParam('in_role_user') != "" ) {
- return $this->getRequest()->getParam('in_role_user');
+ return (int)$this->getRequest()->getParam('in_role_user');
}
$roleId = ( $this->getRequest()->getParam('rid') > 0 ) ? $this->getRequest()->getParam('rid') : Mage::registry('RID');
$users = Mage::getModel('api/roles')->setId($roleId)->getRoleUsers();
diff --git app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Super/Config.php app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Super/Config.php
index 16390685723..79eea75cda2 100644
--- app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Super/Config.php
+++ app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Super/Config.php
@@ -155,6 +155,8 @@ class Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Super_Config extends Mage_Ad
// Hide price if needed
foreach ($attributes as &$attribute) {
$attribute['label'] = $this->escapeHtml($attribute['label']);
+ $attribute['frontend_label'] = $this->escapeHtml($attribute['frontend_label']);
+ $attribute['store_label'] = $this->escapeHtml($attribute['store_label']);
if (isset($attribute['values']) && is_array($attribute['values'])) {
foreach ($attribute['values'] as &$attributeValue) {
if (!$this->getCanReadPrice()) {
diff --git app/code/core/Mage/Adminhtml/Block/Newsletter/Queue/Preview.php app/code/core/Mage/Adminhtml/Block/Newsletter/Queue/Preview.php
index be865af6b7a..871c32130bf 100644
--- app/code/core/Mage/Adminhtml/Block/Newsletter/Queue/Preview.php
+++ app/code/core/Mage/Adminhtml/Block/Newsletter/Queue/Preview.php
@@ -56,6 +56,12 @@ class Mage_Adminhtml_Block_Newsletter_Queue_Preview extends Mage_Adminhtml_Block
if(!$storeId) {
$storeId = Mage::app()->getDefaultStoreView()->getId();
}
+ $template->setTemplateStyles(
+ $this->maliciousCodeFilter($template->getTemplateStyles())
+ );
+ $template->setTemplateText(
+ $this->maliciousCodeFilter($template->getTemplateText())
+ );
Varien_Profiler::start("newsletter_queue_proccessing");
$vars = array();
diff --git app/code/core/Mage/Adminhtml/Block/Newsletter/Template/Preview.php app/code/core/Mage/Adminhtml/Block/Newsletter/Template/Preview.php
index 0612e0ce163..6110084b75f 100644
--- app/code/core/Mage/Adminhtml/Block/Newsletter/Template/Preview.php
+++ app/code/core/Mage/Adminhtml/Block/Newsletter/Template/Preview.php
@@ -46,6 +46,12 @@ class Mage_Adminhtml_Block_Newsletter_Template_Preview extends Mage_Adminhtml_Bl
$template->setTemplateText($this->getRequest()->getParam('text'));
$template->setTemplateStyles($this->getRequest()->getParam('styles'));
}
+ $template->setTemplateStyles(
+ $this->maliciousCodeFilter($template->getTemplateStyles())
+ );
+ $template->setTemplateText(
+ $this->maliciousCodeFilter($template->getTemplateText())
+ );
$storeId = (int)$this->getRequest()->getParam('store_id');
if(!$storeId) {
diff --git app/code/core/Mage/Adminhtml/Block/Permissions/Role/Grid/User.php app/code/core/Mage/Adminhtml/Block/Permissions/Role/Grid/User.php
index 00a2d1d3e89..91e291cc536 100644
--- app/code/core/Mage/Adminhtml/Block/Permissions/Role/Grid/User.php
+++ app/code/core/Mage/Adminhtml/Block/Permissions/Role/Grid/User.php
@@ -157,7 +157,7 @@ class Mage_Adminhtml_Block_Permissions_Role_Grid_User extends Mage_Adminhtml_Blo
protected function _getUsers($json=false)
{
if ( $this->getRequest()->getParam('in_role_user') != "" ) {
- return $this->getRequest()->getParam('in_role_user');
+ return (int)$this->getRequest()->getParam('in_role_user');
}
$roleId = ( $this->getRequest()->getParam('rid') > 0 ) ? $this->getRequest()->getParam('rid') : Mage::registry('RID');
$users = Mage::getModel('admin/roles')->setId($roleId)->getRoleUsers();
diff --git app/code/core/Mage/Adminhtml/Block/Sales/Creditmemo/Grid.php app/code/core/Mage/Adminhtml/Block/Sales/Creditmemo/Grid.php
index 2054d2c7727..e8dc3b5ad2e 100644
--- app/code/core/Mage/Adminhtml/Block/Sales/Creditmemo/Grid.php
+++ app/code/core/Mage/Adminhtml/Block/Sales/Creditmemo/Grid.php
@@ -76,6 +76,7 @@ class Mage_Adminhtml_Block_Sales_Creditmemo_Grid extends Mage_Adminhtml_Block_Wi
'header' => Mage::helper('sales')->__('Order #'),
'index' => 'order_increment_id',
'type' => 'text',
+ 'escape' => true,
));
$this->addColumn('order_created_at', array(
diff --git app/code/core/Mage/Adminhtml/Block/Sales/Invoice/Grid.php app/code/core/Mage/Adminhtml/Block/Sales/Invoice/Grid.php
index fb74a8f5395..3de55ad0c8b 100644
--- app/code/core/Mage/Adminhtml/Block/Sales/Invoice/Grid.php
+++ app/code/core/Mage/Adminhtml/Block/Sales/Invoice/Grid.php
@@ -77,6 +77,7 @@ class Mage_Adminhtml_Block_Sales_Invoice_Grid extends Mage_Adminhtml_Block_Widge
'header' => Mage::helper('sales')->__('Order #'),
'index' => 'order_increment_id',
'type' => 'text',
+ 'escape' => true,
));
$this->addColumn('order_created_at', array(
diff --git app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Header.php app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Header.php
index ff2cbf72c0f..eb900518d33 100644
--- app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Header.php
+++ app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Header.php
@@ -34,7 +34,10 @@ class Mage_Adminhtml_Block_Sales_Order_Create_Header extends Mage_Adminhtml_Bloc
protected function _toHtml()
{
if ($this->_getSession()->getOrder()->getId()) {
- return '<h3 class="icon-head head-sales-order">'.Mage::helper('sales')->__('Edit Order #%s', $this->_getSession()->getOrder()->getIncrementId()).'</h3>';
+ return '<h3 class="icon-head head-sales-order">' . Mage::helper('sales')->__(
+ 'Edit Order #%s',
+ $this->escapeHtml($this->_getSession()->getOrder()->getIncrementId())
+ ) . '</h3>';
}
$customerId = $this->getCustomerId();
diff --git app/code/core/Mage/Adminhtml/Block/Sales/Order/Creditmemo/Create.php app/code/core/Mage/Adminhtml/Block/Sales/Order/Creditmemo/Create.php
index 952f116126b..9737d2cb0d2 100644
--- app/code/core/Mage/Adminhtml/Block/Sales/Order/Creditmemo/Create.php
+++ app/code/core/Mage/Adminhtml/Block/Sales/Order/Creditmemo/Create.php
@@ -67,10 +67,15 @@ class Mage_Adminhtml_Block_Sales_Order_Creditmemo_Create extends Mage_Adminhtml_
public function getHeaderText()
{
if ($this->getCreditmemo()->getInvoice()) {
- $header = Mage::helper('sales')->__('New Credit Memo for Invoice #%s', $this->getCreditmemo()->getInvoice()->getIncrementId());
- }
- else {
- $header = Mage::helper('sales')->__('New Credit Memo for Order #%s', $this->getCreditmemo()->getOrder()->getRealOrderId());
+ $header = Mage::helper('sales')->__(
+ 'New Credit Memo for Invoice #%s',
+ $this->escapeHtml($this->getCreditmemo()->getInvoice()->getIncrementId())
+ );
+ } else {
+ $header = Mage::helper('sales')->__(
+ 'New Credit Memo for Order #%s',
+ $this->escapeHtml($this->getCreditmemo()->getOrder()->getRealOrderId())
+ );
}
return $header;
diff --git app/code/core/Mage/Adminhtml/Block/Sales/Order/Grid.php app/code/core/Mage/Adminhtml/Block/Sales/Order/Grid.php
index 6a976c93ff2..1f9f5be9e97 100644
--- app/code/core/Mage/Adminhtml/Block/Sales/Order/Grid.php
+++ app/code/core/Mage/Adminhtml/Block/Sales/Order/Grid.php
@@ -65,10 +65,11 @@ class Mage_Adminhtml_Block_Sales_Order_Grid extends Mage_Adminhtml_Block_Widget_
{
$this->addColumn('real_order_id', array(
- 'header'=> Mage::helper('sales')->__('Order #'),
- 'width' => '80px',
- 'type' => 'text',
- 'index' => 'increment_id',
+ 'header' => Mage::helper('sales')->__('Order #'),
+ 'width' => '80px',
+ 'type' => 'text',
+ 'index' => 'increment_id',
+ 'escape' => true,
));
if (!Mage::app()->isSingleStoreMode()) {
diff --git app/code/core/Mage/Adminhtml/Block/Sales/Order/Invoice/Create.php app/code/core/Mage/Adminhtml/Block/Sales/Order/Invoice/Create.php
index bf0023f6fe1..01755f7eb3d 100644
--- app/code/core/Mage/Adminhtml/Block/Sales/Order/Invoice/Create.php
+++ app/code/core/Mage/Adminhtml/Block/Sales/Order/Invoice/Create.php
@@ -64,8 +64,14 @@ class Mage_Adminhtml_Block_Sales_Order_Invoice_Create extends Mage_Adminhtml_Blo
public function getHeaderText()
{
return ($this->getInvoice()->getOrder()->getForcedDoShipmentWithInvoice())
- ? Mage::helper('sales')->__('New Invoice and Shipment for Order #%s', $this->getInvoice()->getOrder()->getRealOrderId())
- : Mage::helper('sales')->__('New Invoice for Order #%s', $this->getInvoice()->getOrder()->getRealOrderId());
+ ? Mage::helper('sales')->__(
+ 'New Invoice and Shipment for Order #%s',
+ $this->escapeHtml($this->getInvoice()->getOrder()->getRealOrderId())
+ )
+ : Mage::helper('sales')->__(
+ 'New Invoice for Order #%s',
+ $this->escapeHtml($this->getInvoice()->getOrder()->getRealOrderId())
+ );
}
/**
diff --git app/code/core/Mage/Adminhtml/Block/Sales/Order/Shipment/Create.php app/code/core/Mage/Adminhtml/Block/Sales/Order/Shipment/Create.php
index 8fe63a73e7e..9c8ea34124c 100644
--- app/code/core/Mage/Adminhtml/Block/Sales/Order/Shipment/Create.php
+++ app/code/core/Mage/Adminhtml/Block/Sales/Order/Shipment/Create.php
@@ -59,7 +59,10 @@ class Mage_Adminhtml_Block_Sales_Order_Shipment_Create extends Mage_Adminhtml_Bl
public function getHeaderText()
{
- $header = Mage::helper('sales')->__('New Shipment for Order #%s', $this->getShipment()->getOrder()->getRealOrderId());
+ $header = Mage::helper('sales')->__(
+ 'New Shipment for Order #%s',
+ $this->escapeHtml($this->getShipment()->getOrder()->getRealOrderId())
+ );
return $header;
}
diff --git app/code/core/Mage/Adminhtml/Block/Sales/Order/View.php app/code/core/Mage/Adminhtml/Block/Sales/Order/View.php
index ac41314314f..c4b6f197edc 100644
--- app/code/core/Mage/Adminhtml/Block/Sales/Order/View.php
+++ app/code/core/Mage/Adminhtml/Block/Sales/Order/View.php
@@ -295,6 +295,16 @@ class Mage_Adminhtml_Block_Sales_Order_View extends Mage_Adminhtml_Block_Widget_
{
return $this->getUrl('*/*/reviewPayment', array('action' => $action));
}
+
+ /**
+ * Return header for view grid
+ *
+ * @return string
+ */
+ public function getHeaderHtml()
+ {
+ return '<h3 class="' . $this->getHeaderCssClass() . '">' . $this->escapeHtml($this->getHeaderText()) . '</h3>';
+ }
//
// /**
// * Return URL for accept payment action
diff --git app/code/core/Mage/Adminhtml/Block/Sales/Shipment/Grid.php app/code/core/Mage/Adminhtml/Block/Sales/Shipment/Grid.php
index 1ffe3ba13af..84ad1bfdbf6 100644
--- app/code/core/Mage/Adminhtml/Block/Sales/Shipment/Grid.php
+++ app/code/core/Mage/Adminhtml/Block/Sales/Shipment/Grid.php
@@ -88,6 +88,7 @@ class Mage_Adminhtml_Block_Sales_Shipment_Grid extends Mage_Adminhtml_Block_Widg
'header' => Mage::helper('sales')->__('Order #'),
'index' => 'order_increment_id',
'type' => 'text',
+ 'escape' => true,
));
$this->addColumn('order_created_at', array(
diff --git app/code/core/Mage/Adminhtml/Block/Sales/Transactions/Grid.php app/code/core/Mage/Adminhtml/Block/Sales/Transactions/Grid.php
index c8f8fe5fe14..7c87fb3b2c6 100644
--- app/code/core/Mage/Adminhtml/Block/Sales/Transactions/Grid.php
+++ app/code/core/Mage/Adminhtml/Block/Sales/Transactions/Grid.php
@@ -82,7 +82,8 @@ class Mage_Adminhtml_Block_Sales_Transactions_Grid extends Mage_Adminhtml_Block_
$this->addColumn('increment_id', array(
'header' => Mage::helper('sales')->__('Order ID'),
'index' => 'increment_id',
- 'type' => 'text'
+ 'type' => 'text',
+ 'escape' => true,
));
$this->addColumn('txn_id', array(
diff --git app/code/core/Mage/Adminhtml/Block/System/Email/Template/Preview.php app/code/core/Mage/Adminhtml/Block/System/Email/Template/Preview.php
index 80cdb05fe1d..70e6efe8b7c 100644
--- app/code/core/Mage/Adminhtml/Block/System/Email/Template/Preview.php
+++ app/code/core/Mage/Adminhtml/Block/System/Email/Template/Preview.php
@@ -51,11 +51,12 @@ class Mage_Adminhtml_Block_System_Email_Template_Preview extends Mage_Adminhtml_
$template->setTemplateStyles($this->getRequest()->getParam('styles'));
}
- /* @var $filter Mage_Core_Model_Input_Filter_MaliciousCode */
- $filter = Mage::getSingleton('core/input_filter_maliciousCode');
+ $template->setTemplateStyles(
+ $this->maliciousCodeFilter($template->getTemplateStyles())
+ );
$template->setTemplateText(
- $filter->filter($template->getTemplateText())
+ $this->maliciousCodeFilter($template->getTemplateText())
);
Varien_Profiler::start("email_template_proccessing");
diff --git app/code/core/Mage/Adminhtml/Block/Template.php app/code/core/Mage/Adminhtml/Block/Template.php
index a750e7f3b13..de3be49944c 100644
--- app/code/core/Mage/Adminhtml/Block/Template.php
+++ app/code/core/Mage/Adminhtml/Block/Template.php
@@ -80,4 +80,15 @@ class Mage_Adminhtml_Block_Template extends Mage_Core_Block_Template
Mage::dispatchEvent('adminhtml_block_html_before', array('block' => $this));
return parent::_toHtml();
}
+
+ /**
+ * Deleting script tags from string
+ *
+ * @param string $html
+ * @return string
+ */
+ public function maliciousCodeFilter($html)
+ {
+ return Mage::getSingleton('core/input_filter_maliciousCode')->filter($html);
+ }
}
diff --git app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column/Renderer/Abstract.php app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column/Renderer/Abstract.php
index 786864e37a1..dd145444729 100644
--- app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column/Renderer/Abstract.php
+++ app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column/Renderer/Abstract.php
@@ -114,9 +114,9 @@ abstract class Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
}
$out = '<a href="#" name="' . $this->getColumn()->getId() . '" title="' . $nDir
. '" class="' . $className . '"><span class="sort-title">'
- . $this->getColumn()->getHeader().'</span></a>';
+ . $this->escapeHtml($this->getColumn()->getHeader()) . '</span></a>';
} else {
- $out = $this->getColumn()->getHeader();
+ $out = $this->escapeHtml($this->getColumn()->getHeader());
}
return $out;
}
diff --git app/code/core/Mage/Adminhtml/Model/LayoutUpdate/Validator.php app/code/core/Mage/Adminhtml/Model/LayoutUpdate/Validator.php
index 84389b17507..ea92ac4d484 100644
--- app/code/core/Mage/Adminhtml/Model/LayoutUpdate/Validator.php
+++ app/code/core/Mage/Adminhtml/Model/LayoutUpdate/Validator.php
@@ -180,8 +180,11 @@ class Mage_Adminhtml_Model_LayoutUpdate_Validator extends Zend_Validate_Abstract
protected function _getXpathBlockValidationExpression() {
$xpath = "";
if (count($this->_disallowedBlock)) {
- $xpath = "//block[@type='";
- $xpath .= implode("'] | //block[@type='", $this->_disallowedBlock) . "']";
+ foreach ($this->_disallowedBlock as $key => $value) {
+ $xpath .= $key > 0 ? " | " : '';
+ $xpath .= "//block[translate(@type, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz') = ";
+ $xpath .= "translate('$value', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz')]";
+ }
}
return $xpath;
}
diff --git app/code/core/Mage/Adminhtml/Model/System/Config/Backend/Baseurl.php app/code/core/Mage/Adminhtml/Model/System/Config/Backend/Baseurl.php
index 9e2563a0e1a..f21c2b55d11 100644
--- app/code/core/Mage/Adminhtml/Model/System/Config/Backend/Baseurl.php
+++ app/code/core/Mage/Adminhtml/Model/System/Config/Backend/Baseurl.php
@@ -35,6 +35,8 @@ class Mage_Adminhtml_Model_System_Config_Backend_Baseurl extends Mage_Core_Model
$parsedUrl = parse_url($value);
if (!isset($parsedUrl['scheme']) || !isset($parsedUrl['host'])) {
Mage::throwException(Mage::helper('core')->__('The %s you entered is invalid. Please make sure that it follows "http://domain.com/" format.', $this->getFieldConfig()->label));
+ } elseif (('https' != $parsedUrl['scheme']) && ('http' != $parsedUrl['scheme'])) {
+ Mage::throwException(Mage::helper('core')->__('Invalid URL scheme.'));
}
}
diff --git app/code/core/Mage/Adminhtml/Model/System/Config/Backend/Locale.php app/code/core/Mage/Adminhtml/Model/System/Config/Backend/Locale.php
index 19ee8d6d79d..0d268f672b8 100644
--- app/code/core/Mage/Adminhtml/Model/System/Config/Backend/Locale.php
+++ app/code/core/Mage/Adminhtml/Model/System/Config/Backend/Locale.php
@@ -34,6 +34,27 @@
*/
class Mage_Adminhtml_Model_System_Config_Backend_Locale extends Mage_Core_Model_Config_Data
{
+ /**
+ * Validate data before save data
+ *
+ * @return Mage_Core_Model_Abstract
+ * @throws Mage_Core_Exception
+ */
+ protected function _beforeSave()
+ {
+ $allCurrenciesOptions = Mage::getSingleton('adminhtml/system_config_source_locale_currency_all')
+ ->toOptionArray(true);
+
+ $allCurrenciesValues = array_column($allCurrenciesOptions, 'value');
+
+ foreach ($this->getValue() as $currency) {
+ if (!in_array($currency, $allCurrenciesValues)) {
+ Mage::throwException(Mage::helper('adminhtml')->__('Currency doesn\'t exist.'));
+ }
+ }
+
+ return parent::_beforeSave();
+ }
/**
* Enter description here...
diff --git app/code/core/Mage/Adminhtml/Model/System/Config/Backend/Serialized/Array.php app/code/core/Mage/Adminhtml/Model/System/Config/Backend/Serialized/Array.php
index df16b1a1e3a..f1769d917d0 100644
--- app/code/core/Mage/Adminhtml/Model/System/Config/Backend/Serialized/Array.php
+++ app/code/core/Mage/Adminhtml/Model/System/Config/Backend/Serialized/Array.php
@@ -31,11 +31,19 @@
class Mage_Adminhtml_Model_System_Config_Backend_Serialized_Array extends Mage_Adminhtml_Model_System_Config_Backend_Serialized
{
/**
- * Unset array element with '__empty' key
+ * Check object existence in incoming data and unset array element with '__empty' key
*
+ * @throws Mage_Core_Exception
+ * @return void
*/
protected function _beforeSave()
{
+ try {
+ Mage::helper('core/unserializeArray')->unserialize(serialize($this->getValue()));
+ } catch (Exception $e) {
+ Mage::throwException(Mage::helper('adminhtml')->__('Serialized data is incorrect'));
+ }
+
$value = $this->getValue();
if (is_array($value)) {
unset($value['__empty']);
diff --git app/code/core/Mage/Adminhtml/controllers/Catalog/Product/AttributeController.php app/code/core/Mage/Adminhtml/controllers/Catalog/Product/AttributeController.php
index 0fb2835f535..5b95386c2e4 100644
--- app/code/core/Mage/Adminhtml/controllers/Catalog/Product/AttributeController.php
+++ app/code/core/Mage/Adminhtml/controllers/Catalog/Product/AttributeController.php
@@ -157,6 +157,7 @@ class Mage_Adminhtml_Catalog_Product_AttributeController extends Mage_Adminhtml_
/** @var $helperCatalog Mage_Catalog_Helper_Data */
$helperCatalog = Mage::helper('catalog');
//labels
+ $data['frontend_label'] = (array) $data['frontend_label'];
foreach ($data['frontend_label'] as & $value) {
if ($value) {
$value = $helperCatalog->stripTags($value);
diff --git app/code/core/Mage/Adminhtml/controllers/Catalog/Product/ReviewController.php app/code/core/Mage/Adminhtml/controllers/Catalog/Product/ReviewController.php
index d8440d3e0d5..3e4c866e0a4 100644
--- app/code/core/Mage/Adminhtml/controllers/Catalog/Product/ReviewController.php
+++ app/code/core/Mage/Adminhtml/controllers/Catalog/Product/ReviewController.php
@@ -41,6 +41,17 @@ class Mage_Adminhtml_Catalog_Product_ReviewController extends Mage_Adminhtml_Con
*/
protected $_publicActions = array('edit');
+ /**
+ * Controller predispatch method
+ *
+ * @return Mage_Adminhtml_Controller_Action
+ */
+ public function preDispatch()
+ {
+ $this->_setForcedFormKeyActions(array('delete', 'massDelete'));
+ return parent::preDispatch();
+ }
+
public function indexAction()
{
$this->_title($this->__('Catalog'))
diff --git app/code/core/Mage/Adminhtml/controllers/Catalog/ProductController.php app/code/core/Mage/Adminhtml/controllers/Catalog/ProductController.php
index 6daf0a0a827..d389b5f8ebe 100644
--- app/code/core/Mage/Adminhtml/controllers/Catalog/ProductController.php
+++ app/code/core/Mage/Adminhtml/controllers/Catalog/ProductController.php
@@ -541,7 +541,7 @@ class Mage_Adminhtml_Catalog_ProductController extends Mage_Adminhtml_Controller
catch (Mage_Eav_Model_Entity_Attribute_Exception $e) {
$response->setError(true);
$response->setAttribute($e->getAttributeCode());
- $response->setMessage($e->getMessage());
+ $response->setMessage(Mage::helper('core')->escapeHtml($e->getMessage()));
} catch (Mage_Core_Exception $e) {
$response->setError(true);
$response->setMessage($e->getMessage());
diff --git app/code/core/Mage/Adminhtml/controllers/Checkout/AgreementController.php app/code/core/Mage/Adminhtml/controllers/Checkout/AgreementController.php
index 12483a0b819..ea808e1efd6 100644
--- app/code/core/Mage/Adminhtml/controllers/Checkout/AgreementController.php
+++ app/code/core/Mage/Adminhtml/controllers/Checkout/AgreementController.php
@@ -33,6 +33,17 @@
*/
class Mage_Adminhtml_Checkout_AgreementController extends Mage_Adminhtml_Controller_Action
{
+ /**
+ * Controller predispatch method
+ *
+ * @return Mage_Adminhtml_Controller_Action
+ */
+ public function preDispatch()
+ {
+ $this->_setForcedFormKeyActions('delete');
+ return parent::preDispatch();
+ }
+
public function indexAction()
{
$this->_title($this->__('Sales'))->_title($this->__('Terms and Conditions'));
diff --git app/code/core/Mage/Adminhtml/controllers/Newsletter/TemplateController.php app/code/core/Mage/Adminhtml/controllers/Newsletter/TemplateController.php
index 0894876a67c..2f5cea0c013 100644
--- app/code/core/Mage/Adminhtml/controllers/Newsletter/TemplateController.php
+++ app/code/core/Mage/Adminhtml/controllers/Newsletter/TemplateController.php
@@ -167,6 +167,11 @@ class Mage_Adminhtml_Newsletter_TemplateController extends Mage_Adminhtml_Contro
}
try {
+ $allowedHtmlTags = ['text', 'styles'];
+ if (Mage::helper('adminhtml')->hasTags($request->getParams(), $allowedHtmlTags)) {
+ Mage::throwException(Mage::helper('adminhtml')->__('Invalid template data.'));
+ }
+
$template->addData($request->getParams())
->setTemplateSubject($request->getParam('subject'))
->setTemplateCode($request->getParam('code'))
diff --git app/code/core/Mage/Adminhtml/controllers/Promo/CatalogController.php app/code/core/Mage/Adminhtml/controllers/Promo/CatalogController.php
index 548285c0613..8f602698259 100644
--- app/code/core/Mage/Adminhtml/controllers/Promo/CatalogController.php
+++ app/code/core/Mage/Adminhtml/controllers/Promo/CatalogController.php
@@ -133,6 +133,9 @@ class Mage_Adminhtml_Promo_CatalogController extends Mage_Adminhtml_Controller_A
array('request' => $this->getRequest())
);
$data = $this->getRequest()->getPost();
+ if (Mage::helper('adminhtml')->hasTags($data['rule'], array('attribute'), false)) {
+ Mage::throwException(Mage::helper('catalogrule')->__('Wrong rule specified'));
+ }
$data = $this->_filterDates($data, array('from_date', 'to_date'));
if ($id = $this->getRequest()->getParam('rule_id')) {
$model->load($id);
diff --git app/code/core/Mage/Adminhtml/controllers/Promo/QuoteController.php app/code/core/Mage/Adminhtml/controllers/Promo/QuoteController.php
index 7806a075b59..95cf84d920c 100644
--- app/code/core/Mage/Adminhtml/controllers/Promo/QuoteController.php
+++ app/code/core/Mage/Adminhtml/controllers/Promo/QuoteController.php
@@ -133,6 +133,9 @@ class Mage_Adminhtml_Promo_QuoteController extends Mage_Adminhtml_Controller_Act
'adminhtml_controller_salesrule_prepare_save',
array('request' => $this->getRequest()));
$data = $this->getRequest()->getPost();
+ if (Mage::helper('adminhtml')->hasTags($data['rule'], array('attribute'), false)) {
+ Mage::throwException(Mage::helper('catalogrule')->__('Wrong rule specified'));
+ }
$data = $this->_filterDates($data, array('from_date', 'to_date'));
$id = $this->getRequest()->getParam('rule_id');
if ($id) {
diff --git app/code/core/Mage/Adminhtml/controllers/Sales/Order/CreateController.php app/code/core/Mage/Adminhtml/controllers/Sales/Order/CreateController.php
index 376afd7bf17..261786df417 100644
--- app/code/core/Mage/Adminhtml/controllers/Sales/Order/CreateController.php
+++ app/code/core/Mage/Adminhtml/controllers/Sales/Order/CreateController.php
@@ -146,6 +146,13 @@ class Mage_Adminhtml_Sales_Order_CreateController extends Mage_Adminhtml_Control
* Saving order data
*/
if ($data = $this->getRequest()->getPost('order')) {
+ if (
+ array_key_exists('comment', $data)
+ && array_key_exists('reserved_order_id', $data['comment'])
+ ) {
+ unset($data['comment']['reserved_order_id']);
+ }
+
$this->_getOrderCreateModel()->importPostData($data);
}
@@ -476,10 +483,20 @@ class Mage_Adminhtml_Sales_Order_CreateController extends Mage_Adminhtml_Control
/**
* Saving quote and create order
+ *
+ * @throws Mage_Core_Exception
*/
public function saveAction()
{
try {
+ $orderData = $this->getRequest()->getPost('order');
+ if (
+ array_key_exists('reserved_order_id', $orderData['comment'])
+ && Mage::helper('adminhtml/sales')->hasTags($orderData['comment']['reserved_order_id'])
+ ) {
+ Mage::throwException($this->__('Invalid order data.'));
+ }
+
$this->_processActionData('save');
if ($paymentData = $this->getRequest()->getPost('payment')) {
$this->_getOrderCreateModel()->setPaymentData($paymentData);
diff --git app/code/core/Mage/Adminhtml/controllers/SitemapController.php app/code/core/Mage/Adminhtml/controllers/SitemapController.php
index 4f5c381c57e..847133f76f4 100644
--- app/code/core/Mage/Adminhtml/controllers/SitemapController.php
+++ app/code/core/Mage/Adminhtml/controllers/SitemapController.php
@@ -33,6 +33,11 @@
*/
class Mage_Adminhtml_SitemapController extends Mage_Adminhtml_Controller_Action
{
+ /**
+ * Maximum sitemap name length
+ */
+ const MAXIMUM_SITEMAP_NAME_LENGTH = 32;
+
/**
* Controller predispatch method
*
@@ -141,6 +146,19 @@ class Mage_Adminhtml_SitemapController extends Mage_Adminhtml_Controller_Action
if (!empty($data['sitemap_filename']) && !empty($data['sitemap_path'])) {
$path = rtrim($data['sitemap_path'], '\\/')
. DS . $data['sitemap_filename'];
+
+ // check filename length
+ if (strlen($data['sitemap_filename']) > self::MAXIMUM_SITEMAP_NAME_LENGTH) {
+ Mage::getSingleton('adminhtml/session')->addError(
+ Mage::helper('sitemap')->__(
+ 'Please enter a sitemap name with at most %s characters.',
+ self::MAXIMUM_SITEMAP_NAME_LENGTH
+ ));
+ $this->_redirect('*/*/edit', array(
+ 'sitemap_id' => $this->getRequest()->getParam('sitemap_id')
+ ));
+ return;
+ }
/** @var $validator Mage_Core_Model_File_Validator_AvailablePath */
$validator = Mage::getModel('core/file_validator_availablePath');
/** @var $helper Mage_Adminhtml_Helper_Catalog */
diff --git app/code/core/Mage/Adminhtml/controllers/System/Email/TemplateController.php app/code/core/Mage/Adminhtml/controllers/System/Email/TemplateController.php
index 1310399fc49..66ddbf2c13d 100644
--- app/code/core/Mage/Adminhtml/controllers/System/Email/TemplateController.php
+++ app/code/core/Mage/Adminhtml/controllers/System/Email/TemplateController.php
@@ -89,6 +89,11 @@ class Mage_Adminhtml_System_Email_TemplateController extends Mage_Adminhtml_Cont
$this->renderLayout();
}
+ /**
+ * Save action
+ *
+ * @throws Mage_Core_Exception
+ */
public function saveAction()
{
$request = $this->getRequest();
@@ -102,6 +107,11 @@ class Mage_Adminhtml_System_Email_TemplateController extends Mage_Adminhtml_Cont
}
try {
+ $allowedHtmlTags = ['template_text', 'styles'];
+ if (Mage::helper('adminhtml')->hasTags($request->getParams(), $allowedHtmlTags)) {
+ Mage::throwException(Mage::helper('adminhtml')->__('Invalid template data.'));
+ }
+
$template->setTemplateSubject($request->getParam('template_subject'))
->setTemplateCode($request->getParam('template_code'))
/*
diff --git app/code/core/Mage/Catalog/Helper/Product.php app/code/core/Mage/Catalog/Helper/Product.php
old mode 100755
new mode 100644
index 3b2659bcf01..77230c6270e
--- app/code/core/Mage/Catalog/Helper/Product.php
+++ app/code/core/Mage/Catalog/Helper/Product.php
@@ -468,4 +468,41 @@ class Mage_Catalog_Helper_Product extends Mage_Core_Helper_Url
{
return $this->_skipSaleableCheck;
}
+
+ /**
+ * Get default product value by field name
+ *
+ * @param string $fieldName
+ * @param string $productType
+ * @return int
+ */
+ public function getDefaultProductValue($fieldName, $productType)
+ {
+ $fieldData = $this->getFieldset($fieldName) ? (array) $this->getFieldset($fieldName) : null;
+ if (
+ count($fieldData)
+ && array_key_exists($productType, $fieldData['product_type'])
+ && (bool)$fieldData['use_config']
+ ) {
+ return $fieldData['inventory'];
+ }
+ return self::DEFAULT_QTY;
+ }
+
+ /**
+ * Return array from config by fieldset name and area
+ *
+ * @param null|string $field
+ * @param string $fieldset
+ * @param string $area
+ * @return array|null
+ */
+ public function getFieldset($field = null, $fieldset = 'catalog_product_dataflow', $area = 'admin')
+ {
+ $fieldsetData = Mage::getConfig()->getFieldset($fieldset, $area);
+ if ($fieldsetData) {
+ return $fieldsetData ? $fieldsetData->$field : $fieldsetData;
+ }
+ return $fieldsetData;
+ }
}
diff --git app/code/core/Mage/Catalog/Model/Product/Option/Type/File.php.orig app/code/core/Mage/Catalog/Model/Product/Option/Type/File.php.orig
deleted file mode 100644
index 5e9bdea59bb..00000000000
--- app/code/core/Mage/Catalog/Model/Product/Option/Type/File.php.orig
+++ /dev/null
@@ -1,823 +0,0 @@
-<?php
-/**
- * Magento
- *
- * NOTICE OF LICENSE
- *
- * This source file is subject to the Open Software License (OSL 3.0)
- * that is bundled with this package in the file LICENSE.txt.
- * It is also available through the world-wide-web at this URL:
- * http://opensource.org/licenses/osl-3.0.php
- * If you did not receive a copy of the license and are unable to
- * obtain it through the world-wide-web, please send an email
- * to license@magentocommerce.com so we can send you a copy immediately.
- *
- * DISCLAIMER
- *
- * Do not edit or add to this file if you wish to upgrade Magento to newer
- * versions in the future. If you wish to customize Magento for your
- * needs please refer to http://www.magentocommerce.com for more information.
- *
- * @category Mage
- * @package Mage_Catalog
- * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
- */
-
-/**
- * Catalog product option file type
- *
- * @category Mage
- * @package Mage_Catalog
- * @author Magento Core Team <core@magentocommerce.com>
- */
-class Mage_Catalog_Model_Product_Option_Type_File extends Mage_Catalog_Model_Product_Option_Type_Default
-{
- /**
- * Url for custom option download controller
- * @var string
- */
- protected $_customOptionDownloadUrl = 'sales/download/downloadCustomOption';
-
- public function isCustomizedView()
- {
- return true;
- }
-
- /**
- * Return option html
- *
- * @param array $optionInfo
- * @return string
- */
- public function getCustomizedView($optionInfo)
- {
- try {
- if (isset($optionInfo['option_value'])) {
- return $this->_getOptionHtml($optionInfo['option_value']);
- } elseif (isset($optionInfo['value'])) {
- return $optionInfo['value'];
- }
- } catch (Exception $e) {
- return $optionInfo['value'];
- }
- }
-
- /**
- * Returns additional params for processing options
- *
- * @return Varien_Object
- */
- protected function _getProcessingParams()
- {
- $buyRequest = $this->getRequest();
- $params = $buyRequest->getData('_processing_params');
- /*
- * Notice check for params to be Varien_Object - by using object we protect from
- * params being forged and contain data from user frontend input
- */
- if ($params instanceof Varien_Object) {
- return $params;
- }
- return new Varien_Object();
- }
-
- /**
- * Returns file info array if we need to get file from already existing file.
- * Or returns null, if we need to get file from uploaded array.
- *
- * @return null|array
- */
- protected function _getCurrentConfigFileInfo()
- {
- $option = $this->getOption();
- $optionId = $option->getId();
- $processingParams = $this->_getProcessingParams();
- $buyRequest = $this->getRequest();
-
- // Check maybe restore file from config requested
- $optionActionKey = 'options_' . $optionId . '_file_action';
- if ($buyRequest->getData($optionActionKey) == 'save_old') {
- $fileInfo = array();
- $currentConfig = $processingParams->getCurrentConfig();
- if ($currentConfig) {
- $fileInfo = $currentConfig->getData('options/' . $optionId);
- }
- return $fileInfo;
- }
- return null;
- }
-
- /**
- * Validate user input for option
- *
- * @throws Mage_Core_Exception
- * @param array $values All product option values, i.e. array (option_id => mixed, option_id => mixed...)
- * @return Mage_Catalog_Model_Product_Option_Type_File
- */
- public function validateUserValue($values)
- {
- Mage::getSingleton('checkout/session')->setUseNotice(false);
-
- $this->setIsValid(true);
- $option = $this->getOption();
-
- /*
- * Check whether we receive uploaded file or restore file by: reorder/edit configuration or
- * previous configuration with no newly uploaded file
- */
- $fileInfo = null;
- if (isset($values[$option->getId()]) && is_array($values[$option->getId()])) {
- // Legacy style, file info comes in array with option id index
- $fileInfo = $values[$option->getId()];
- } else {
- /*
- * New recommended style - file info comes in request processing parameters and we
- * sure that this file info originates from Magento, not from manually formed POST request
- */
- $fileInfo = $this->_getCurrentConfigFileInfo();
- }
- if ($fileInfo !== null) {
- if (is_array($fileInfo) && $this->_validateFile($fileInfo)) {
- $value = $fileInfo;
- } else {
- $value = null;
- }
- $this->setUserValue($value);
- return $this;
- }
-
- // Process new uploaded file
- try {
- $this->_validateUploadedFile();
- } catch (Exception $e) {
- if ($this->getSkipCheckRequiredOption()) {
- $this->setUserValue(null);
- return $this;
- } else {
- Mage::throwException($e->getMessage());
- }
- }
- return $this;
- }
-
- /**
- * Validate uploaded file
- *
- * @throws Mage_Core_Exception
- * @return Mage_Catalog_Model_Product_Option_Type_File
- */
- protected function _validateUploadedFile()
- {
- $option = $this->getOption();
- $processingParams = $this->_getProcessingParams();
-
- /**
- * Upload init
- */
- $upload = new Zend_File_Transfer_Adapter_Http();
- $file = $processingParams->getFilesPrefix() . 'options_' . $option->getId() . '_file';
- try {
- $runValidation = $option->getIsRequire() || $upload->isUploaded($file);
- if (!$runValidation) {
- $this->setUserValue(null);
- return $this;
- }
-
- $fileInfo = $upload->getFileInfo($file);
- $fileInfo = $fileInfo[$file];
- $fileInfo['title'] = $fileInfo['name'];
-
- } catch (Exception $e) {
- // when file exceeds the upload_max_filesize, $_FILES is empty
- if (isset($_SERVER['CONTENT_LENGTH']) && $_SERVER['CONTENT_LENGTH'] > $this->_getUploadMaxFilesize()) {
- $this->setIsValid(false);
- $value = $this->_bytesToMbytes($this->_getUploadMaxFilesize());
- Mage::throwException(
- Mage::helper('catalog')->__("The file you uploaded is larger than %s Megabytes allowed by server", $value)
- );
- } else {
- switch($this->getProcessMode())
- {
- case Mage_Catalog_Model_Product_Type_Abstract::PROCESS_MODE_FULL:
- Mage::throwException(
- Mage::helper('catalog')->__('Please specify the product\'s required option(s).')
- );
- break;
- default:
- $this->setUserValue(null);
- break;
- }
- return $this;
- }
- }
-
- /**
- * Option Validations
- */
-
- // Image dimensions
- $_dimentions = array();
- if ($option->getImageSizeX() > 0) {
- $_dimentions['maxwidth'] = $option->getImageSizeX();
- }
- if ($option->getImageSizeY() > 0) {
- $_dimentions['maxheight'] = $option->getImageSizeY();
- }
- if (count($_dimentions) > 0) {
- $upload->addValidator('ImageSize', false, $_dimentions);
- }
-
- // File extension
- $_allowed = $this->_parseExtensionsString($option->getFileExtension());
- if ($_allowed !== null) {
- $upload->addValidator('Extension', false, $_allowed);
- } else {
- $_forbidden = $this->_parseExtensionsString($this->getConfigData('forbidden_extensions'));
- if ($_forbidden !== null) {
- $upload->addValidator('ExcludeExtension', false, $_forbidden);
- }
- }
-
- // Maximum filesize
- $upload->addValidator('FilesSize', false, array('max' => $this->_getUploadMaxFilesize()));
-
- /**
- * Upload process
- */
-
- $this->_initFilesystem();
-
- if ($upload->isUploaded($file) && $upload->isValid($file)) {
-
- $extension = pathinfo(strtolower($fileInfo['name']), PATHINFO_EXTENSION);
-
- $fileName = Mage_Core_Model_File_Uploader::getCorrectFileName($fileInfo['name']);
- $dispersion = Mage_Core_Model_File_Uploader::getDispretionPath($fileName);
-
- $filePath = $dispersion;
- $fileHash = md5(file_get_contents($fileInfo['tmp_name']));
- $filePath .= DS . $fileHash . '.' . $extension;
- $fileFullPath = $this->getQuoteTargetDir() . $filePath;
-
- $upload->addFilter('Rename', array(
- 'target' => $fileFullPath,
- 'overwrite' => true
- ));
-
- $this->getProduct()->getTypeInstance(true)->addFileQueue(array(
- 'operation' => 'receive_uploaded_file',
- 'src_name' => $file,
- 'dst_name' => $fileFullPath,
- 'uploader' => $upload,
- 'option' => $this,
- ));
-
- $_width = 0;
- $_height = 0;
- if (is_readable($fileInfo['tmp_name'])) {
- $_imageSize = getimagesize($fileInfo['tmp_name']);
- if ($_imageSize) {
- $_width = $_imageSize[0];
- $_height = $_imageSize[1];
- }