-
Notifications
You must be signed in to change notification settings - Fork 141
/
PATCH_SUPEE-7405_CE_1.4.0.0_v1-2016-01-20-06-38-35.sh
1491 lines (1432 loc) · 66.5 KB
/
PATCH_SUPEE-7405_CE_1.4.0.0_v1-2016-01-20-06-38-35.sh
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
#!/bin/bash
# Patch apllying tool template
# v0.1.2
# (c) Copyright 2013. Magento Inc.
#
# DO NOT CHANGE ANY LINE IN THIS FILE.
# 1. Check required system tools
_check_installed_tools() {
local missed=""
until [ -z "$1" ]; do
type -t $1 >/dev/null 2>/dev/null
if (( $? != 0 )); then
missed="$missed $1"
fi
shift
done
echo $missed
}
REQUIRED_UTILS='sed patch'
MISSED_REQUIRED_TOOLS=`_check_installed_tools $REQUIRED_UTILS`
if (( `echo $MISSED_REQUIRED_TOOLS | wc -w` > 0 ));
then
echo -e "Error! Some required system tools, that are utilized in this sh script, are not installed:\nTool(s) \"$MISSED_REQUIRED_TOOLS\" is(are) missed, please install it(them)."
exit 1
fi
# 2. Determine bin path for system tools
CAT_BIN=`which cat`
PATCH_BIN=`which patch`
SED_BIN=`which sed`
PWD_BIN=`which pwd`
BASENAME_BIN=`which basename`
BASE_NAME=`$BASENAME_BIN "$0"`
# 3. Help menu
if [ "$1" = "-?" -o "$1" = "-h" -o "$1" = "--help" ]
then
$CAT_BIN << EOFH
Usage: sh $BASE_NAME [--help] [-R|--revert] [--list]
Apply embedded patch.
-R, --revert Revert previously applied embedded patch
--list Show list of applied patches
--help Show this help message
EOFH
exit 0
fi
# 4. Get "revert" flag and "list applied patches" flag
REVERT_FLAG=
SHOW_APPLIED_LIST=0
if [ "$1" = "-R" -o "$1" = "--revert" ]
then
REVERT_FLAG=-R
fi
if [ "$1" = "--list" ]
then
SHOW_APPLIED_LIST=1
fi
# 5. File pathes
CURRENT_DIR=`$PWD_BIN`/
APP_ETC_DIR=`echo "$CURRENT_DIR""app/etc/"`
APPLIED_PATCHES_LIST_FILE=`echo "$APP_ETC_DIR""applied.patches.list"`
# 6. Show applied patches list if requested
if [ "$SHOW_APPLIED_LIST" -eq 1 ] ; then
echo -e "Applied/reverted patches list:"
if [ -e "$APPLIED_PATCHES_LIST_FILE" ]
then
if [ ! -r "$APPLIED_PATCHES_LIST_FILE" ]
then
echo "ERROR: \"$APPLIED_PATCHES_LIST_FILE\" must be readable so applied patches list can be shown."
exit 1
else
$SED_BIN -n "/SUP-\|SUPEE-/p" $APPLIED_PATCHES_LIST_FILE
fi
else
echo "<empty>"
fi
exit 0
fi
# 7. Check applied patches track file and its directory
_check_files() {
if [ ! -e "$APP_ETC_DIR" ]
then
echo "ERROR: \"$APP_ETC_DIR\" must exist for proper tool work."
exit 1
fi
if [ ! -w "$APP_ETC_DIR" ]
then
echo "ERROR: \"$APP_ETC_DIR\" must be writeable for proper tool work."
exit 1
fi
if [ -e "$APPLIED_PATCHES_LIST_FILE" ]
then
if [ ! -w "$APPLIED_PATCHES_LIST_FILE" ]
then
echo "ERROR: \"$APPLIED_PATCHES_LIST_FILE\" must be writeable for proper tool work."
exit 1
fi
fi
}
_check_files
# 8. Apply/revert patch
# Note: there is no need to check files permissions for files to be patched.
# "patch" tool will not modify any file if there is not enough permissions for all files to be modified.
# Get start points for additional information and patch data
SKIP_LINES=$((`$SED_BIN -n "/^__PATCHFILE_FOLLOWS__$/=" "$CURRENT_DIR""$BASE_NAME"` + 1))
ADDITIONAL_INFO_LINE=$(($SKIP_LINES - 3))p
_apply_revert_patch() {
DRY_RUN_FLAG=
if [ "$1" = "dry-run" ]
then
DRY_RUN_FLAG=" --dry-run"
echo "Checking if patch can be applied/reverted successfully..."
fi
PATCH_APPLY_REVERT_RESULT=`$SED_BIN -e '1,/^__PATCHFILE_FOLLOWS__$/d' "$CURRENT_DIR""$BASE_NAME" | $PATCH_BIN $DRY_RUN_FLAG $REVERT_FLAG -p0`
PATCH_APPLY_REVERT_STATUS=$?
if [ $PATCH_APPLY_REVERT_STATUS -eq 1 ] ; then
echo -e "ERROR: Patch can't be applied/reverted successfully.\n\n$PATCH_APPLY_REVERT_RESULT"
exit 1
fi
if [ $PATCH_APPLY_REVERT_STATUS -eq 2 ] ; then
echo -e "ERROR: Patch can't be applied/reverted successfully."
exit 2
fi
}
REVERTED_PATCH_MARK=
if [ -n "$REVERT_FLAG" ]
then
REVERTED_PATCH_MARK=" | REVERTED"
fi
_apply_revert_patch dry-run
_apply_revert_patch
# 9. Track patch applying result
echo "Patch was applied/reverted successfully."
ADDITIONAL_INFO=`$SED_BIN -n ""$ADDITIONAL_INFO_LINE"" "$CURRENT_DIR""$BASE_NAME"`
APPLIED_REVERTED_ON_DATE=`date -u +"%F %T UTC"`
APPLIED_REVERTED_PATCH_INFO=`echo -n "$APPLIED_REVERTED_ON_DATE"" | ""$ADDITIONAL_INFO""$REVERTED_PATCH_MARK"`
echo -e "$APPLIED_REVERTED_PATCH_INFO\n$PATCH_APPLY_REVERT_RESULT\n\n" >> "$APPLIED_PATCHES_LIST_FILE"
exit 0
SUPEE-7405-CE-1-4-0-0 | CE_1.4.0.0 | v1 | ee5b1d84e76670ce2e0039ef8991d44cc9ad4af4 | Sat Jan 16 12:19:05 2016 +0200 | bd31e66297..ee5b1d84e7
__PATCHFILE_FOLLOWS__
diff --git app/code/core/Mage/Admin/Model/Mysql4/User.php app/code/core/Mage/Admin/Model/Mysql4/User.php
index 38f2cec..91e469c 100644
--- app/code/core/Mage/Admin/Model/Mysql4/User.php
+++ app/code/core/Mage/Admin/Model/Mysql4/User.php
@@ -121,16 +121,13 @@ class Mage_Admin_Model_Mysql4_User extends Mage_Core_Model_Mysql4_Abstract
protected function _afterSave(Mage_Core_Model_Abstract $user)
{
- $user->setExtra(unserialize($user->getExtra()));
+ $this->_unserializeExtraData($user);
return $this;
}
protected function _afterLoad(Mage_Core_Model_Abstract $user)
{
- if (is_string($user->getExtra())) {
- $user->setExtra(unserialize($user->getExtra()));
- }
- return parent::_afterLoad($user);
+ return parent::_afterLoad($this->_unserializeExtraData($user));
}
public function load(Mage_Core_Model_Abstract $user, $value, $field=null)
@@ -287,4 +284,21 @@ class Mage_Admin_Model_Mysql4_User extends Mage_Core_Model_Mysql4_Abstract
}
return $this;
}
+
+ /**
+ * Unserializes user extra data
+ *
+ * @param Mage_Core_Model_Abstract $user
+ * @return Mage_Core_Model_Abstract
+ */
+ protected function _unserializeExtraData(Mage_Core_Model_Abstract $user)
+ {
+ try {
+ $unsterilizedData = Mage::helper('core/unserializeArray')->unserialize($user->getExtra());
+ $user->setExtra($unsterilizedData);
+ } catch (Exception $e) {
+ $user->setExtra(false);
+ }
+ return $user;
+ }
}
diff --git app/code/core/Mage/Admin/Model/Observer.php app/code/core/Mage/Admin/Model/Observer.php
index 1f78f49..1b35542 100644
--- app/code/core/Mage/Admin/Model/Observer.php
+++ app/code/core/Mage/Admin/Model/Observer.php
@@ -33,31 +33,47 @@
*/
class Mage_Admin_Model_Observer
{
- public function actionPreDispatchAdmin($event)
+ public function actionPreDispatchAdmin($observer)
{
- $session = Mage::getSingleton('admin/session');
- /* @var $session Mage_Admin_Model_Session */
+ /** @var $session Mage_Admin_Model_Session */
+ $session = Mage::getSingleton('admin/session');
- /**
- * @var $request Mage_Core_Controller_Request_Http
- */
+ /** @var $request Mage_Core_Controller_Request_Http */
$request = Mage::app()->getRequest();
$user = $session->getUser();
- if ($request->getActionName() == 'forgotpassword' || $request->getActionName() == 'logout') {
+ $requestedActionName = strtolower($request->getActionName());
+ $openActions = array(
+ 'forgotpassword',
+ );
+ if (in_array($requestedActionName, $openActions)) {
$request->setDispatched(true);
- }
- else {
+ } else {
if ($user) {
$user->reload();
}
if (!$user || !$user->getId()) {
if ($request->getPost('login')) {
- $postLogin = $request->getPost('login');
- $username = isset($postLogin['username']) ? $postLogin['username'] : '';
- $password = isset($postLogin['password']) ? $postLogin['password'] : '';
- $user = $session->login($username, $password, $request);
- $request->setPost('login', null);
+
+ /** @var Mage_Core_Model_Session $coreSession */
+ $coreSession = Mage::getSingleton('core/session');
+
+ if ($coreSession->validateFormKey($request->getPost("form_key"))) {
+ $postLogin = $request->getPost('login');
+ $username = isset($postLogin['username']) ? $postLogin['username'] : '';
+ $password = isset($postLogin['password']) ? $postLogin['password'] : '';
+ $session->login($username, $password, $request);
+ $request->setPost('login', null);
+ } else {
+ if ($request && !$request->getParam('messageSent')) {
+ Mage::getSingleton('adminhtml/session')->addError(
+ Mage::helper('adminhtml')->__('Invalid Form Key. Please refresh the page.')
+ );
+ $request->setParam('messageSent', true);
+ }
+ }
+
+ $coreSession->renewFormKey();
}
if (!$request->getInternallyForwarded()) {
$request->setInternallyForwarded();
@@ -66,8 +82,7 @@ class Mage_Admin_Model_Observer
->setControllerName('index')
->setActionName('deniedIframe')
->setDispatched(false);
- }
- elseif ($request->getParam('isAjax')) {
+ } elseif ($request->getParam('isAjax')) {
$request->setParam('forwarded', true)
->setControllerName('index')
->setActionName('deniedJson')
diff --git app/code/core/Mage/Admin/Model/Redirectpolicy.php app/code/core/Mage/Admin/Model/Redirectpolicy.php
new file mode 100644
index 0000000..2dad8af
--- /dev/null
+++ app/code/core/Mage/Admin/Model/Redirectpolicy.php
@@ -0,0 +1,72 @@
+<?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_Admin
+ * @copyright Copyright (c) 2014 Magento Inc. (http://www.magentocommerce.com)
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
+ */
+
+/**
+ * Admin redirect policy model, guard admin from direct link to store/category/product deletion
+ *
+ * @category Mage
+ * @package Mage_Admin
+ * @author Magento Core Team <core@magentocommerce.com>
+ */
+class Mage_Admin_Model_Redirectpolicy
+{
+ /**
+ * @var Mage_Adminhtml_Model_Url
+ */
+ protected $_urlModel;
+
+ /**
+ * @param array $parameters array('urlModel' => object)
+ */
+ public function __construct($parameters = array())
+ {
+ /** @var Mage_Adminhtml_Model_Url _urlModel */
+ $this->_urlModel = (!empty($parameters['urlModel'])) ?
+ $parameters['urlModel'] : Mage::getModel('adminhtml/url');
+ }
+
+ /**
+ * Redirect to startup page after logging in if request contains any params (except security key)
+ *
+ * @param Mage_Admin_Model_User $user
+ * @param Zend_Controller_Request_Http $request
+ * @param string|null $alternativeUrl
+ * @return null|string
+ */
+ public function getRedirectUrl(Mage_Admin_Model_User $user, Zend_Controller_Request_Http $request = null,
+ $alternativeUrl = null)
+ {
+ if (empty($request)) {
+ return;
+ }
+ $countRequiredParams = ($this->_urlModel->useSecretKey()
+ && $request->getParam(Mage_Adminhtml_Model_Url::SECRET_KEY_PARAM_NAME)) ? 1 : 0;
+ $countGetParams = count($request->getUserParams()) + count($request->getQuery());
+
+ return ($countGetParams > $countRequiredParams) ?
+ $this->_urlModel->getUrl($user->getStartupPageUrl()) : $alternativeUrl;
+ }
+}
diff --git app/code/core/Mage/Admin/Model/Session.php app/code/core/Mage/Admin/Model/Session.php
index 19a144f..feb555f 100644
--- app/code/core/Mage/Admin/Model/Session.php
+++ app/code/core/Mage/Admin/Model/Session.php
@@ -43,11 +43,38 @@ class Mage_Admin_Model_Session extends Mage_Core_Model_Session_Abstract
protected $_isFirstPageAfterLogin;
/**
+ * @var Mage_Admin_Model_Redirectpolicy
+ */
+ protected $_urlPolicy;
+
+ /**
+ * @var Mage_Core_Controller_Response_Http
+ */
+ protected $_response;
+
+ /**
+ * @var Mage_Core_Model_Factory
+ */
+ protected $_factory;
+
+ /**
* Class constructor
*
*/
- public function __construct()
+ public function __construct($parameters = array())
{
+ /** @var Mage_Admin_Model_Redirectpolicy _urlPolicy */
+ $this->_urlPolicy = (!empty($parameters['redirectPolicy'])) ?
+ $parameters['redirectPolicy'] : Mage::getModel('admin/redirectpolicy');
+
+ /** @var Mage_Core_Controller_Response_Http _response */
+ $this->_response = (!empty($parameters['response'])) ?
+ $parameters['response'] : new Mage_Core_Controller_Response_Http();
+
+ /** @var $user Mage_Core_Model_Factory */
+ $this->_factory = (!empty($parameters['factory'])) ?
+ $parameters['factory'] : Mage::getModel('core/factory');
+
$this->init('admin');
}
@@ -67,7 +94,7 @@ class Mage_Admin_Model_Session extends Mage_Core_Model_Session_Abstract
try {
/* @var $user Mage_Admin_Model_User */
- $user = Mage::getModel('admin/user');
+ $user = $this->_factory->getModel('admin/user');
$user->login($username, $password);
if ($user->getId()) {
@@ -78,14 +105,17 @@ class Mage_Admin_Model_Session extends Mage_Core_Model_Session_Abstract
$session->setIsFirstVisit(true);
$session->setUser($user);
$session->setAcl(Mage::getResourceModel('admin/acl')->loadAcl());
- if ($requestUri = $this->_getRequestUri($request)) {
- Mage::dispatchEvent('admin_session_user_login_success', array('user'=>$user));
- header('Location: ' . $requestUri);
- exit;
+
+ $alternativeUrl = $this->_getRequestUri($request);
+ $redirectUrl = $this->_urlPolicy->getRedirectUrl($user, $request, $alternativeUrl);
+ if ($redirectUrl) {
+ Mage::dispatchEvent('admin_session_user_login_success', array('user' => $user));
+ $this->_response->clearHeaders()
+ ->setRedirect($redirectUrl)
+ ->sendHeadersAndExit();
}
- }
- else {
- Mage::throwException(Mage::helper('adminhtml')->__('Invalid Username or Password.'));
+ } else {
+ Mage::throwException(Mage::helper('adminhtml')->__('Invalid User Name or Password.'));
}
}
catch (Mage_Core_Exception $e) {
diff --git app/code/core/Mage/Admin/Model/User.php app/code/core/Mage/Admin/Model/User.php
index 9e093ff..6ca0320 100644
--- app/code/core/Mage/Admin/Model/User.php
+++ app/code/core/Mage/Admin/Model/User.php
@@ -375,7 +375,7 @@ class Mage_Admin_Model_User extends Mage_Core_Model_Abstract
*/
public function validate()
{
- $errors = array();
+ $errors = new ArrayObject();
if (!Zend_Validate::is($this->getUsername(), 'NotEmpty')) {
$errors[] = Mage::helper('adminhtml')->__('User Name is required field.');
@@ -405,16 +405,21 @@ class Mage_Admin_Model_User extends Mage_Core_Model_Abstract
if ($this->hasPasswordConfirmation() && $this->getNewPassword() != $this->getPasswordConfirmation()) {
$errors[] = Mage::helper('adminhtml')->__('Password confirmation must be same as password.');
}
+
+ Mage::dispatchEvent('admin_user_validate', array(
+ 'user' => $this,
+ 'errors' => $errors,
+ ));
}
if ($this->userExists()) {
- $errors[] = Mage::helper('adminhtml')->__('User with the same User Name or Email aleady exists');
+ $errors[] = Mage::helper('adminhtml')->__('A user with the same user name or email aleady exists.');
}
- if (empty($errors)) {
+ if (count($errors) === 0) {
return true;
}
- return $errors;
+ return (array)$errors;
}
}
diff --git app/code/core/Mage/Adminhtml/Block/Sales/Order/View/Tab/History.php app/code/core/Mage/Adminhtml/Block/Sales/Order/View/Tab/History.php
index 668fc41..f33df8e 100644
--- app/code/core/Mage/Adminhtml/Block/Sales/Order/View/Tab/History.php
+++ app/code/core/Mage/Adminhtml/Block/Sales/Order/View/Tab/History.php
@@ -162,7 +162,14 @@ class Mage_Adminhtml_Block_Sales_Order_View_Tab_History
*/
public function getItemComment(array $item)
{
- return (isset($item['comment']) ? $this->htmlEscape($item['comment']) : '');
+ $strItemComment = '';
+ if (isset($item['comment'])) {
+ $allowedTags = array('b', 'br', 'strong', 'i', 'u', 'a');
+ /** @var Mage_Adminhtml_Helper_Sales $salesHelper */
+ $salesHelper = Mage::helper('adminhtml/sales');
+ $strItemComment = $salesHelper->escapeHtmlWithLinks($item['comment'], $allowedTags);
+ }
+ return $strItemComment;
}
/**
diff --git app/code/core/Mage/Adminhtml/Helper/Catalog/Product/Edit/Action/Attribute.php app/code/core/Mage/Adminhtml/Helper/Catalog/Product/Edit/Action/Attribute.php
index ff0329d..14e00f1 100644
--- app/code/core/Mage/Adminhtml/Helper/Catalog/Product/Edit/Action/Attribute.php
+++ app/code/core/Mage/Adminhtml/Helper/Catalog/Product/Edit/Action/Attribute.php
@@ -96,7 +96,7 @@ class Mage_Adminhtml_Helper_Catalog_Product_Edit_Action_Attribute extends Mage_C
{
$session = Mage::getSingleton('adminhtml/session');
- if ($this->_getRequest()->isPost() && $this->_getRequest()->getActionName()=='edit') {
+ if ($this->_getRequest()->isPost() && strtolower($this->_getRequest()->getActionName()) == 'edit') {
$session->setProductIds($this->_getRequest()->getParam('product', null));
}
diff --git app/code/core/Mage/Adminhtml/Helper/Sales.php app/code/core/Mage/Adminhtml/Helper/Sales.php
index 8cd356d..804a499 100644
--- app/code/core/Mage/Adminhtml/Helper/Sales.php
+++ app/code/core/Mage/Adminhtml/Helper/Sales.php
@@ -84,4 +84,46 @@ class Mage_Adminhtml_Helper_Sales extends Mage_Core_Helper_Abstract
return $res;
}
+ /**
+ * Escape string preserving links
+ *
+ * @param array|string $data
+ * @param null|array $allowedTags
+ * @return string
+ */
+ public function escapeHtmlWithLinks($data, $allowedTags = null)
+ {
+ if (!empty($data) && is_array($allowedTags) && in_array('a', $allowedTags)) {
+ $links = [];
+ $i = 1;
+ $regexp = "/<a\s[^>]*href\s*?=\s*?([\"\']??)([^\" >]*?)\\1[^>]*>(.*)<\/a>/siU";
+ while (preg_match($regexp, $data, $matches)) {
+ //Revert the sprintf escaping
+ $url = str_replace('%%', '%', $matches[2]);
+ $text = str_replace('%%', '%', $matches[3]);
+ //Check for an valid url
+ if ($url) {
+ $urlScheme = strtolower(parse_url($url, PHP_URL_SCHEME));
+ if ($urlScheme !== 'http' && $urlScheme !== 'https') {
+ $url = null;
+ }
+ }
+ //Use hash tag as fallback
+ if (!$url) {
+ $url = '#';
+ }
+ //Recreate a minimalistic secure a tag
+ $links[] = sprintf(
+ '<a href="%s">%s</a>',
+ htmlspecialchars($url, ENT_QUOTES, 'UTF-8', false),
+ parent::escapeHtml($text)
+ );
+ $data = str_replace($matches[0], '%' . $i . '$s', $data);
+ ++$i;
+ }
+ $data = parent::escapeHtml($data, $allowedTags);
+ return vsprintf($data, $links);
+ }
+ return parent::escapeHtml($data, $allowedTags);
+ }
}
diff --git app/code/core/Mage/Adminhtml/controllers/IndexController.php app/code/core/Mage/Adminhtml/controllers/IndexController.php
index 69822bf..b3eb2a2 100644
--- app/code/core/Mage/Adminhtml/controllers/IndexController.php
+++ app/code/core/Mage/Adminhtml/controllers/IndexController.php
@@ -172,36 +172,43 @@ class Mage_Adminhtml_IndexController extends Mage_Adminhtml_Controller_Action
public function forgotpasswordAction ()
{
- $email = $this->getRequest()->getParam('email');
+ $email = '';
$params = $this->getRequest()->getParams();
- if (!empty($email) && !empty($params)) {
- $collection = Mage::getResourceModel('admin/user_collection');
- /* @var $collection Mage_Admin_Model_Mysql4_User_Collection */
- $collection->addFieldToFilter('email', $email);
- $collection->load(false);
-
- if ($collection->getSize() > 0) {
- foreach ($collection as $item) {
- $user = Mage::getModel('admin/user')->load($item->getId());
- if ($user->getId()) {
- $pass = substr(md5(uniqid(rand(), true)), 0, 7);
- $user->setPassword($pass);
- $user->save();
- $user->setPlainPassword($pass);
- $user->sendNewPasswordEmail();
- Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('adminhtml')->__('A new password was sent to your email address. Please check your email and click Back to Login.'));
- $email = '';
+ if (!empty($params)) {
+ $email = (string)$this->getRequest()->getParam('email');
+
+ if ($this->_validateFormKey()) {
+ if (!empty($email)) {
+ $collection = Mage::getResourceModel('admin/user_collection');
+ /* @var $collection Mage_Admin_Model_Mysql4_User_Collection */
+ $collection->addFieldToFilter('email', $email);
+ $collection->load(false);
+
+ if ($collection->getSize() > 0) {
+ foreach ($collection as $item) {
+ $user = Mage::getModel('admin/user')->load($item->getId());
+ if ($user->getId()) {
+ $pass = Mage::helper('core')->getRandomString(7);
+ $user->setPassword($pass);
+ $user->save();
+ $user->setPlainPassword($pass);
+ $user->sendNewPasswordEmail();
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('adminhtml')->__('A new password was sent to your email address. Please check your email and click Back to Login.'));
+ $email = '';
+ }
+ break;
+ }
+ } else {
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('adminhtml')->__('Cannot find the email address.'));
}
- break;
+ } else {
+ $this->_getSession()->addError($this->__('Invalid email address.'));
}
} else {
- Mage::getSingleton('adminhtml/session')->addError(Mage::helper('adminhtml')->__('Can\'t find email address.'));
+ $this->_getSession()->addError($this->__('Invalid Form Key. Please refresh the page.'));
}
- } elseif (!empty($params)) {
- Mage::getSingleton('adminhtml/session')->addError(Mage::helper('adminhtml')->__('Email address is empty.'));
}
-
$data = array(
'email' => $email
);
diff --git app/code/core/Mage/Catalog/Block/Product/View/Options/Type/Select.php app/code/core/Mage/Catalog/Block/Product/View/Options/Type/Select.php
index ff0cabf..a4f5261 100644
--- app/code/core/Mage/Catalog/Block/Product/View/Options/Type/Select.php
+++ app/code/core/Mage/Catalog/Block/Product/View/Options/Type/Select.php
@@ -103,7 +103,7 @@ class Mage_Catalog_Block_Product_View_Options_Type_Select
));
$selectHtml .= '<li>' .
'<input type="'.$type.'" class="'.$class.' '.$require.' product-custom-option" onclick="opConfig.reloadPrice()" name="options['.$_option->getId().']'.$arraySign.'" id="options_'.$_option->getId().'_'.$count.'" value="'.$_value->getOptionTypeId().'" />' .
- '<span class="label"><label for="options_'.$_option->getId().'_'.$count.'">'.$_value->getTitle().' '.$priceStr.'</label></span>';
+ '<span class="label"><label for="options_'.$_option->getId().'_'.$count.'">' . $this->escapeHtml($_value->getTitle()) . ' '.$priceStr.'</label></span>';
if ($_option->getIsRequire()) {
$selectHtml .= '<script type="text/javascript">' .
'$(\'options_'.$_option->getId().'_'.$count.'\').advaiceContainer = \'options-'.$_option->getId().'-container\';' .
diff --git app/code/core/Mage/Checkout/Block/Cart/Item/Renderer.php app/code/core/Mage/Checkout/Block/Cart/Item/Renderer.php
index aaa2a00..2949a7e 100644
--- app/code/core/Mage/Checkout/Block/Cart/Item/Renderer.php
+++ app/code/core/Mage/Checkout/Block/Cart/Item/Renderer.php
@@ -216,6 +216,7 @@ class Mage_Checkout_Block_Cart_Item_Renderer extends Mage_Core_Block_Template
'checkout/cart/delete',
array(
'id'=>$this->getItem()->getId(),
+ 'form_key' => Mage::getSingleton('core/session')->getFormKey(),
Mage_Core_Controller_Front_Action::PARAM_NAME_URL_ENCODED => $this->helper('core/url')->getEncodedUrl()
)
);
diff --git app/code/core/Mage/Checkout/controllers/CartController.php app/code/core/Mage/Checkout/controllers/CartController.php
index 5ed3c37..186c087 100644
--- app/code/core/Mage/Checkout/controllers/CartController.php
+++ app/code/core/Mage/Checkout/controllers/CartController.php
@@ -79,7 +79,7 @@ class Mage_Checkout_CartController extends Mage_Core_Controller_Front_Action
$this->getResponse()->setRedirect($backUrl);
} else {
- if (($this->getRequest()->getActionName() == 'add') && !$this->getRequest()->getParam('in_cart')) {
+ if ((strtolower($this->getRequest()->getActionName()) == 'add') && !$this->getRequest()->getParam('in_cart')) {
$this->_getSession()->setContinueShoppingUrl($this->_getRefererUrl());
}
$this->_redirect('checkout/cart');
@@ -285,15 +285,21 @@ class Mage_Checkout_CartController extends Mage_Core_Controller_Front_Action
*/
public function deleteAction()
{
- $id = (int) $this->getRequest()->getParam('id');
- if ($id) {
- try {
- $this->_getCart()->removeItem($id)
- ->save();
- } catch (Exception $e) {
- $this->_getSession()->addError($this->__('Cannot remove item'));
+ if ($this->_validateFormKey()) {
+ $id = (int)$this->getRequest()->getParam('id');
+ if ($id) {
+ try {
+ $this->_getCart()->removeItem($id)
+ ->save();
+ } catch (Exception $e) {
+ $this->_getSession()->addError($this->__('Cannot remove the item.'));
+ Mage::logException($e);
+ }
}
+ } else {
+ $this->_getSession()->addError($this->__('Cannot remove the item.'));
}
+
$this->_redirectReferer(Mage::getUrl('*/*'));
}
diff --git app/code/core/Mage/Checkout/controllers/OnepageController.php app/code/core/Mage/Checkout/controllers/OnepageController.php
index 246b93f..8b9feaf 100644
--- app/code/core/Mage/Checkout/controllers/OnepageController.php
+++ app/code/core/Mage/Checkout/controllers/OnepageController.php
@@ -65,7 +65,7 @@ class Mage_Checkout_OnepageController extends Mage_Checkout_Controller_Action
$this->_ajaxRedirectResponse();
return true;
}
- $action = $this->getRequest()->getActionName();
+ $action = strtolower($this->getRequest()->getActionName());
if (Mage::getSingleton('checkout/session')->getCartWasUpdated(true)
&& !in_array($action, array('index', 'progress'))) {
$this->_ajaxRedirectResponse();
diff --git app/code/core/Mage/Core/Controller/Response/Http.php app/code/core/Mage/Core/Controller/Response/Http.php
index 6440b02..999332f 100644
--- app/code/core/Mage/Core/Controller/Response/Http.php
+++ app/code/core/Mage/Core/Controller/Response/Http.php
@@ -74,4 +74,13 @@ class Mage_Core_Controller_Response_Http extends Zend_Controller_Response_Http
Mage::dispatchEvent('http_response_send_before', array('response'=>$this));
return parent::sendResponse();
}
+
+ /**
+ * Method send already collected headers and exit from script
+ */
+ public function sendHeadersAndExit()
+ {
+ $this->sendHeaders();
+ exit;
+ }
}
diff --git app/code/core/Mage/Core/Model/App.php app/code/core/Mage/Core/Model/App.php
index 3f5340c..9e65386 100644
--- app/code/core/Mage/Core/Model/App.php
+++ app/code/core/Mage/Core/Model/App.php
@@ -1163,6 +1163,7 @@ class Mage_Core_Model_App
public function dispatchEvent($eventName, $args)
{
+ $eventName = strtolower($eventName);
foreach ($this->_events as $area=>$events) {
if (!isset($events[$eventName])) {
$eventConfig = $this->getConfig()->getEventConfig($area, $eventName);
diff --git app/code/core/Mage/Core/Model/Config.php app/code/core/Mage/Core/Model/Config.php
index e758fca..b2344691 100644
--- app/code/core/Mage/Core/Model/Config.php
+++ app/code/core/Mage/Core/Model/Config.php
@@ -858,6 +858,10 @@ class Mage_Core_Model_Config extends Mage_Core_Model_Config_Base
}
$configFile = $this->getModuleDir('etc', $modName).DS.$fileName;
if ($mergeModel->loadFile($configFile)) {
+ $this->_makeEventsLowerCase(Mage_Core_Model_App_Area::AREA_GLOBAL, $mergeModel);
+ $this->_makeEventsLowerCase(Mage_Core_Model_App_Area::AREA_FRONTEND, $mergeModel);
+ $this->_makeEventsLowerCase(Mage_Core_Model_App_Area::AREA_ADMIN, $mergeModel);
+
$mergeToObject->extend($mergeModel, true);
}
}
@@ -1051,7 +1055,7 @@ class Mage_Core_Model_Config extends Mage_Core_Model_Config_Base
}
foreach ($events as $event) {
- $eventName = $event->getName();
+ $eventName = strtolower($event->getName());
$observers = $event->observers->children();
foreach ($observers as $observer) {
switch ((string)$observer->type) {
@@ -1471,4 +1475,42 @@ class Mage_Core_Model_Config extends Mage_Core_Model_Config_Base
}
return false;
}
+
+ /**
+ * Makes all events to lower-case
+ *
+ * @param string $area
+ * @param Mage_Core_Model_Config_Base $mergeModel
+ */
+ protected function _makeEventsLowerCase($area, Mage_Core_Model_Config_Base $mergeModel)
+ {
+ $events = $mergeModel->getNode($area . "/" . Mage_Core_Model_App_Area::PART_EVENTS);
+ if ($events !== false) {
+ $children = clone $events->children();
+ /** @var Mage_Core_Model_Config_Element $event */
+ foreach ($children as $event) {
+ if ($this->_isNodeNameHasUpperCase($event)) {
+ $oldName = $event->getName();
+ $newEventName = strtolower($oldName);
+ if (!isset($events->$newEventName)) {
+ /** @var Mage_Core_Model_Config_Element $newNode */
+ $newNode = $events->addChild($newEventName, $event);
+ $newNode->extend($event);
+ }
+ unset($events->$oldName);
+ }
+ }
+ }
+ }
+
+ /**
+ * Checks is event name has upper-case letters
+ *
+ * @param Mage_Core_Model_Config_Element $event
+ * @return bool
+ */
+ protected function _isNodeNameHasUpperCase(Mage_Core_Model_Config_Element $event)
+ {
+ return (strtolower($event->getName()) !== (string)$event->getName());
+ }
}
diff --git app/code/core/Mage/Core/Model/Email/Template/Filter.php app/code/core/Mage/Core/Model/Email/Template/Filter.php
index d882110..93f6a9f 100644
--- app/code/core/Mage/Core/Model/Email/Template/Filter.php
+++ app/code/core/Mage/Core/Model/Email/Template/Filter.php
@@ -165,11 +165,14 @@ class Mage_Core_Model_Email_Template_Filter extends Varien_Filter_Template
$skipParams = array('type', 'id', 'output');
$blockParameters = $this->_getIncludeParameters($construction[2]);
$layout = Mage::app()->getLayout();
+ $block = null;
if (isset($blockParameters['type'])) {
if ($this->_permissionBlock->isTypeAllowed($blockParameters['type'])) {
$type = $blockParameters['type'];
$block = $layout->createBlock($type, null, $blockParameters);
+ } else {
+ Mage::log('Security problem: ' . $blockParameters['type'] . ' has not been whitelisted.');
}
} elseif (isset($blockParameters['id'])) {
$block = $layout->createBlock('cms/block');
@@ -186,11 +189,10 @@ class Mage_Core_Model_Email_Template_Filter extends Varien_Filter_Template
}
$block->setDataUsingMethod($k, $v);
}
- }
-
- if (!$block) {
+ } else {
return '';
}
+
if (isset($blockParameters['output'])) {
$method = $blockParameters['output'];
}
diff --git app/code/core/Mage/Core/Model/Factory.php app/code/core/Mage/Core/Model/Factory.php
new file mode 100644
index 0000000..139e653
--- /dev/null
+++ app/code/core/Mage/Core/Model/Factory.php
@@ -0,0 +1,144 @@
+<?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_Core
+ * @copyright Copyright (c) 2006-2015 X.commerce, Inc. (http://www.magento.com)
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
+ */
+
+/**
+ * Factory class
+ *
+ * @category Mage
+ * @package Mage_Core
+ * @author Magento Core Team <core@magentocommerce.com>
+ */
+class Mage_Core_Model_Factory
+{
+ /**
+ * Xml path to url rewrite model class alias
+ */
+ const XML_PATH_URL_REWRITE_MODEL = 'global/url_rewrite/model';
+
+ const XML_PATH_INDEX_INDEX_MODEL = 'global/index/index_model';
+
+ /**
+ * Config instance
+ *
+ * @var Mage_Core_Model_Config
+ */
+ protected $_config;
+
+ /**
+ * Initialize factory
+ *
+ * @param array $arguments
+ */
+ public function __construct(array $arguments = array())
+ {
+ $this->_config = !empty($arguments['config']) ? $arguments['config'] : Mage::getConfig();
+ }
+
+ /**
+ * Retrieve model object
+ *
+ * @param string $modelClass
+ * @param array|object $arguments
+ * @return bool|Mage_Core_Model_Abstract
+ */
+ public function getModel($modelClass = '', $arguments = array())
+ {
+ return Mage::getModel($modelClass, $arguments);
+ }
+
+ /**
+ * Retrieve model object singleton
+ *
+ * @param string $modelClass
+ * @param array $arguments
+ * @return Mage_Core_Model_Abstract
+ */
+ public function getSingleton($modelClass = '', array $arguments = array())
+ {
+ return Mage::getSingleton($modelClass, $arguments);
+ }
+
+ /**
+ * Retrieve object of resource model
+ *
+ * @param string $modelClass
+ * @param array $arguments
+ * @return Object
+ */
+ public function getResourceModel($modelClass, $arguments = array())
+ {
+ return Mage::getResourceModel($modelClass, $arguments);
+ }
+
+ /**
+ * Retrieve helper instance
+ *
+ * @param string $helperClass
+ * @return Mage_Core_Helper_Abstract
+ */
+ public function getHelper($helperClass)
+ {
+ return Mage::helper($helperClass);
+ }
+
+ /**
+ * Get config instance
+ *
+ * @return Mage_Core_Model_Config
+ */
+ public function getConfig()
+ {
+ return $this->_config;
+ }
+
+ /**
+ * Retrieve url_rewrite instance
+ *
+ * @return Mage_Core_Model_Url_Rewrite
+ */
+ public function getUrlRewriteInstance()
+ {
+ return $this->getModel($this->getUrlRewriteClassAlias());
+ }
+
+ /**
+ * Retrieve alias for url_rewrite model
+ *
+ * @return string
+ */
+ public function getUrlRewriteClassAlias()
+ {
+ return (string)$this->_config->getNode(self::XML_PATH_URL_REWRITE_MODEL);
+ }
+
+ /**
+ * @return string
+ */
+ public function getIndexClassAlias()
+ {
+ return (string)$this->_config->getNode(self::XML_PATH_INDEX_INDEX_MODEL);
+ }
+}
diff --git app/code/core/Mage/Core/Model/Session.php app/code/core/Mage/Core/Model/Session.php
index 453b416..ddc8f8e 100644
--- app/code/core/Mage/Core/Model/Session.php
+++ app/code/core/Mage/Core/Model/Session.php
@@ -33,7 +33,7 @@
*/
class Mage_Core_Model_Session extends Mage_Core_Model_Session_Abstract
{