@@ -961,8 +961,9 @@ const WebDiscoveryProject = {
961961 if ( clean_url != url ) {
962962 // they are different, sanity checks
963963 if (
964- ! sanitizeUrl ( clean_url , { testMode : WebDiscoveryProject . testMode } )
965- . safeUrl ||
964+ sanitizeUrl ( clean_url , {
965+ testMode : WebDiscoveryProject . testMode ,
966+ } ) . result !== "safe" ||
966967 WebDiscoveryProject . dropLongURL ( clean_url )
967968 )
968969 return url ;
@@ -1026,7 +1027,10 @@ const WebDiscoveryProject = {
10261027 }
10271028
10281029 // the url is suspicious, this should never be the case here but better safe
1029- if ( ! sanitizeUrl ( url , { testMode : WebDiscoveryProject . testMode } ) . safeUrl ) {
1030+ if (
1031+ sanitizeUrl ( url , { testMode : WebDiscoveryProject . testMode } ) . result !==
1032+ "safe"
1033+ ) {
10301034 return discard ( "URL failed the isSuspiciousURL check" ) ;
10311035 }
10321036
@@ -1725,8 +1729,9 @@ const WebDiscoveryProject = {
17251729
17261730 //Check if the URL is know to be bad: private, about:, odd ports, etc.
17271731 if (
1728- ! sanitizeUrl ( activeURL , { testMode : WebDiscoveryProject . testMode } )
1729- . safeUrl
1732+ sanitizeUrl ( activeURL , {
1733+ testMode : WebDiscoveryProject . testMode ,
1734+ } ) . result !== "safe"
17301735 ) {
17311736 logger . debug ( "[onLocationChange] isSuspiciousURL" , activeURL ) ;
17321737 return ;
@@ -2330,28 +2335,22 @@ const WebDiscoveryProject = {
23302335 }
23312336 }
23322337
2338+ const sanitizedUrl = sanitizeUrl ( linkURL , {
2339+ testMode : WebDiscoveryProject . testMode ,
2340+ } ) ;
23332341 if (
2334- sanitizeUrl ( linkURL , { testMode : WebDiscoveryProject . testMode } )
2335- . safeUrl &&
2342+ sanitizedUrl . result === "safe" &&
23362343 ! WebDiscoveryProject . dropLongURL ( linkURL )
23372344 ) {
23382345 WebDiscoveryProject . isAlreadyMarkedPrivate ( linkURL , function ( _res ) {
23392346 if ( _res && _res [ "private" ] == 0 ) {
23402347 WebDiscoveryProject . state [ "v" ] [ activeURL ] [ "c" ] . push ( {
2341- l :
2342- "" +
2343- sanitizeUrl ( linkURL , {
2344- testMode : WebDiscoveryProject . testMode ,
2345- } ) . safeUrl ,
2348+ l : "" + sanitizedUrl . safeUrl ,
23462349 t : WebDiscoveryProject . counter ,
23472350 } ) ;
23482351 } else if ( ! _res ) {
23492352 WebDiscoveryProject . state [ "v" ] [ activeURL ] [ "c" ] . push ( {
2350- l :
2351- "" +
2352- sanitizeUrl ( linkURL , {
2353- testMode : WebDiscoveryProject . testMode ,
2354- } ) . safeUrl ,
2353+ l : "" + sanitizedUrl . safeUrl ,
23552354 t : WebDiscoveryProject . counter ,
23562355 } ) ;
23572356 }
@@ -2437,7 +2436,7 @@ const WebDiscoveryProject = {
24372436 init : function ( ) {
24382437 return Promise . resolve ( ) . then ( ( ) => {
24392438 logger . debug ( "Init function called:" ) ;
2440- WebDiscoveryProject . log = logger . debug ;
2439+ WebDiscoveryProject . logger = logger ;
24412440 return Promise . resolve ( )
24422441 . then ( ( ) => {
24432442 if ( WebDiscoveryProject . db ) {
@@ -2571,18 +2570,9 @@ const WebDiscoveryProject = {
25712570 // Check if they are suspicious.
25722571 // Check if they are marked private.
25732572 if ( msg . payload . ref ) {
2574- if (
2575- ! sanitizeUrl ( msg . payload [ "ref" ] , {
2576- testMode : WebDiscoveryProject . testMode ,
2577- } ) . safeUrl
2578- ) {
2579- msg . payload [ "ref" ] = null ;
2580- } else {
2581- msg . payload [ "ref" ] = WebDiscoveryProject . sanitizeUrl (
2582- msg . payload [ "ref" ] ,
2583- { testMode : WebDiscoveryProject . testMode } ,
2584- ) ;
2585- }
2573+ msg . payload [ "ref" ] = sanitizeUrl ( msg . payload [ "ref" ] , {
2574+ testMode : WebDiscoveryProject . testMode ,
2575+ } ) . safeUrl ;
25862576
25872577 // Check if ref. exists in bloom filter, then turn ref to null.
25882578 WebDiscoveryProject . isAlreadyMarkedPrivate (
@@ -2659,9 +2649,9 @@ const WebDiscoveryProject = {
26592649
26602650 // check if suspiciousURL
26612651 if (
2662- ! sanitizeUrl ( msg . payload . url , {
2652+ sanitizeUrl ( msg . payload . url , {
26632653 testMode : WebDiscoveryProject . testMode ,
2664- } ) . safeUrl
2654+ } ) . result !== "safe"
26652655 )
26662656 return null ;
26672657
@@ -2670,9 +2660,9 @@ const WebDiscoveryProject = {
26702660 msg . payload . x . canonical_url != ""
26712661 ) {
26722662 if (
2673- ! sanitizeUrl ( msg . payload . x . canonical_url , {
2663+ sanitizeUrl ( msg . payload . x . canonical_url , {
26742664 testMode : WebDiscoveryProject . testMode ,
2675- } ) . safeUrl
2665+ } ) . result !== "safe"
26762666 )
26772667 return null ;
26782668 }
@@ -2681,13 +2671,11 @@ const WebDiscoveryProject = {
26812671 if ( msg . payload . red ) {
26822672 var cleanRed = [ ] ;
26832673 msg . payload . red . forEach ( function ( e ) {
2684- if (
2685- ( sanitizeUrl ( e ) . safeUrl , { testMode : WebDiscoveryProject . testMode } )
2686- ) {
2687- cleanRed . push (
2688- sanitizeUrl ( e , { testMode : WebDiscoveryProject . testMode } )
2689- . safeUrl ,
2690- ) ;
2674+ const safeUrl = sanitizeUrl ( e , {
2675+ testMode : WebDiscoveryProject . testMode ,
2676+ } ) . safeUrl ;
2677+ if ( safeUrl !== null ) {
2678+ cleanRed . push ( safeUrl ) ;
26912679 }
26922680 } ) ;
26932681 msg . payload . red = cleanRed ;
@@ -2775,7 +2763,7 @@ const WebDiscoveryProject = {
27752763 if (
27762764 sanitizeUrl ( msg . payload . r [ eachResult ] . u , {
27772765 testMode : WebDiscoveryProject . testMode ,
2778- } ) . safeUrl
2766+ } ) . result === "safe"
27792767 ) {
27802768 cleanR . push ( msg . payload . r [ eachResult ] ) ;
27812769 }
@@ -2989,7 +2977,10 @@ const WebDiscoveryProject = {
29892977 if ( ! source || source === "openTabs" ) {
29902978 const allOpenPages = await WebDiscoveryProject . getAllOpenPages ( ) ;
29912979 pages = allOpenPages
2992- . map ( ( url ) => ( { url, page_doc : WebDiscoveryProject . state . v [ url ] } ) )
2980+ . map ( ( url ) => ( {
2981+ url,
2982+ page_doc : WebDiscoveryProject . state . v [ url ] ,
2983+ } ) )
29932984 . filter ( ( { url, page_doc } ) => page_doc && isRelevantUrl ( url ) ) ;
29942985 } else if ( source === "unprocessed" ) {
29952986 pages = await new Promise ( ( resolve , reject ) => {
@@ -3461,8 +3452,8 @@ const WebDiscoveryProject = {
34613452
34623453 if (
34633454 queryLikeURL &&
3464- ( ! sanitizeUrl ( query , { testMode : WebDiscoveryProject . testMode } )
3465- . safeUrl ||
3455+ ( sanitizeUrl ( query , { testMode : WebDiscoveryProject . testMode } ) . result !==
3456+ "safe" ||
34663457 WebDiscoveryProject . dropLongURL ( query ) )
34673458 ) {
34683459 logger . debug ( "Query is dangerous" ) ;
@@ -3486,7 +3477,8 @@ const WebDiscoveryProject = {
34863477
34873478 // Check URL is suspicious
34883479 if (
3489- ! sanitizeUrl ( url , { testMode : WebDiscoveryProject . testMode } ) . safeUrl
3480+ sanitizeUrl ( url , { testMode : WebDiscoveryProject . testMode } ) . result !==
3481+ "safe"
34903482 ) {
34913483 logger . debug ( "Url is suspicious" ) ;
34923484 url = "(PROTECTED)" ;
@@ -3859,7 +3851,8 @@ const WebDiscoveryProject = {
38593851 setPrivate = true ;
38603852 logger . debug ( "Setting private because empty page data" ) ;
38613853 } else if (
3862- ! sanitizeUrl ( url , { testMode : WebDiscoveryProject . testMode } ) . safeUrl
3854+ sanitizeUrl ( url , { testMode : WebDiscoveryProject . testMode } )
3855+ . result !== "safe"
38633856 ) {
38643857 // if the url looks private already add it already as checked and private
38653858 let reason = "susp. url" ;
@@ -3965,7 +3958,7 @@ const WebDiscoveryProject = {
39653958 var page_struct_before = page_doc [ "x" ] ;
39663959 url_pagedocPair [ url ] = page_doc ;
39673960
3968- WebDiscoveryProject . log (
3961+ logger . debug (
39693962 "Going for double fetch (url:" ,
39703963 url ,
39713964 ", page_doc:" ,
0 commit comments