File tree Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -540,10 +540,16 @@ plugin.login = function(user, cb) {
540
540
} ;
541
541
542
542
function parseCookie ( cookie , body , cb ) {
543
+ const isCN = config . app === 'leetcode.cn' ;
543
544
const SessionPattern = / L E E T C O D E _ S E S S I O N = ( .+ ?) ( ; | $ ) / ;
544
- const csrfPattern = / c s r f t o k e n = ( .+ ?) ( ; | $ ) / ;
545
+ let csrfPattern ;
546
+ if ( isCN ) {
547
+ csrfPattern = / n a m e = " c s r f m i d d l e w a r e t o k e n " v a l u e = " ( .* ?) " / ;
548
+ } else {
549
+ csrfPattern = / c s r f t o k e n = ( .+ ?) ( ; | $ ) / ;
550
+ }
551
+ const reCsrfResult = csrfPattern . exec ( isCN ? body : cookie ) ;
545
552
const reSessionResult = SessionPattern . exec ( cookie ) ;
546
- const reCsrfResult = csrfPattern . exec ( cookie ) ;
547
553
if ( reSessionResult === null || reCsrfResult === null ) {
548
554
return cb ( 'invalid cookie?' ) ;
549
555
}
You can’t perform that action at this time.
0 commit comments