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) {
540540} ;
541541
542542function parseCookie ( cookie , body , cb ) {
543+ const isCN = config . app === 'leetcode.cn' ;
543544 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 ) ;
545552 const reSessionResult = SessionPattern . exec ( cookie ) ;
546- const reCsrfResult = csrfPattern . exec ( cookie ) ;
547553 if ( reSessionResult === null || reCsrfResult === null ) {
548554 return cb ( 'invalid cookie?' ) ;
549555 }
You can’t perform that action at this time.
0 commit comments