@@ -961,7 +961,9 @@ const WebDiscoveryProject = {
961961 if ( clean_url != url ) {
962962 // they are different, sanity checks
963963 if (
964- sanitizeUrl ( clean_url , { testMode : WebDiscoveryProject . testMode } ) . result !== "safe" ||
964+ sanitizeUrl ( clean_url , {
965+ testMode : WebDiscoveryProject . testMode ,
966+ } ) . result !== "safe" ||
965967 WebDiscoveryProject . dropLongURL ( clean_url )
966968 )
967969 return url ;
@@ -1025,7 +1027,10 @@ const WebDiscoveryProject = {
10251027 }
10261028
10271029 // the url is suspicious, this should never be the case here but better safe
1028- if ( sanitizeUrl ( url , { testMode : WebDiscoveryProject . testMode } ) . result !== "safe" ) {
1030+ if (
1031+ sanitizeUrl ( url , { testMode : WebDiscoveryProject . testMode } ) . result !==
1032+ "safe"
1033+ ) {
10291034 return discard ( "URL failed the isSuspiciousURL check" ) ;
10301035 }
10311036
@@ -1724,8 +1729,9 @@ const WebDiscoveryProject = {
17241729
17251730 //Check if the URL is know to be bad: private, about:, odd ports, etc.
17261731 if (
1727- ! sanitizeUrl ( activeURL , { testMode : WebDiscoveryProject . testMode } )
1728- . safeUrl
1732+ sanitizeUrl ( activeURL , {
1733+ testMode : WebDiscoveryProject . testMode ,
1734+ } ) . result !== "safe"
17291735 ) {
17301736 logger . debug ( "[onLocationChange] isSuspiciousURL" , activeURL ) ;
17311737 return ;
@@ -2329,28 +2335,22 @@ const WebDiscoveryProject = {
23292335 }
23302336 }
23312337
2338+ let sanitizedUrl = sanitizeUrl ( linkURL , {
2339+ testMode : WebDiscoveryProject . testMode ,
2340+ } ) ;
23322341 if (
2333- sanitizeUrl ( linkURL , { testMode : WebDiscoveryProject . testMode } )
2334- . safeUrl &&
2342+ sanitizedUrl . result === "safe" &&
23352343 ! WebDiscoveryProject . dropLongURL ( linkURL )
23362344 ) {
23372345 WebDiscoveryProject . isAlreadyMarkedPrivate ( linkURL , function ( _res ) {
23382346 if ( _res && _res [ "private" ] == 0 ) {
23392347 WebDiscoveryProject . state [ "v" ] [ activeURL ] [ "c" ] . push ( {
2340- l :
2341- "" +
2342- sanitizeUrl ( linkURL , {
2343- testMode : WebDiscoveryProject . testMode ,
2344- } ) . safeUrl ,
2348+ l : "" + sanitizedUrl . safeUrl ,
23452349 t : WebDiscoveryProject . counter ,
23462350 } ) ;
23472351 } else if ( ! _res ) {
23482352 WebDiscoveryProject . state [ "v" ] [ activeURL ] [ "c" ] . push ( {
2349- l :
2350- "" +
2351- sanitizeUrl ( linkURL , {
2352- testMode : WebDiscoveryProject . testMode ,
2353- } ) . safeUrl ,
2353+ l : "" + sanitizedUrl . safeUrl ,
23542354 t : WebDiscoveryProject . counter ,
23552355 } ) ;
23562356 }
@@ -2436,7 +2436,7 @@ const WebDiscoveryProject = {
24362436 init : function ( ) {
24372437 return Promise . resolve ( ) . then ( ( ) => {
24382438 logger . debug ( "Init function called:" ) ;
2439- WebDiscoveryProject . logger = logger
2439+ WebDiscoveryProject . logger = logger ;
24402440 return Promise . resolve ( )
24412441 . then ( ( ) => {
24422442 if ( WebDiscoveryProject . db ) {
@@ -2570,18 +2570,9 @@ const WebDiscoveryProject = {
25702570 // Check if they are suspicious.
25712571 // Check if they are marked private.
25722572 if ( msg . payload . ref ) {
2573- if (
2574- ! sanitizeUrl ( msg . payload [ "ref" ] , {
2575- testMode : WebDiscoveryProject . testMode ,
2576- } ) . safeUrl
2577- ) {
2578- msg . payload [ "ref" ] = null ;
2579- } else {
2580- msg . payload [ "ref" ] = sanitizeUrl (
2581- msg . payload [ "ref" ] ,
2582- { testMode : WebDiscoveryProject . testMode } ,
2583- ) . safeUrl ;
2584- }
2573+ msg . payload [ "ref" ] = sanitizeUrl ( msg . payload [ "ref" ] , {
2574+ testMode : WebDiscoveryProject . testMode ,
2575+ } ) . safeUrl ;
25852576
25862577 // Check if ref. exists in bloom filter, then turn ref to null.
25872578 WebDiscoveryProject . isAlreadyMarkedPrivate (
@@ -2658,9 +2649,9 @@ const WebDiscoveryProject = {
26582649
26592650 // check if suspiciousURL
26602651 if (
2661- ! sanitizeUrl ( msg . payload . url , {
2652+ sanitizeUrl ( msg . payload . url , {
26622653 testMode : WebDiscoveryProject . testMode ,
2663- } ) . safeUrl
2654+ } ) . result !== "safe"
26642655 )
26652656 return null ;
26662657
@@ -2669,9 +2660,9 @@ const WebDiscoveryProject = {
26692660 msg . payload . x . canonical_url != ""
26702661 ) {
26712662 if (
2672- ! sanitizeUrl ( msg . payload . x . canonical_url , {
2663+ sanitizeUrl ( msg . payload . x . canonical_url , {
26732664 testMode : WebDiscoveryProject . testMode ,
2674- } ) . safeUrl
2665+ } ) . result !== "safe"
26752666 )
26762667 return null ;
26772668 }
@@ -2680,11 +2671,11 @@ const WebDiscoveryProject = {
26802671 if ( msg . payload . red ) {
26812672 var cleanRed = [ ] ;
26822673 msg . payload . red . forEach ( function ( e ) {
2683- if ( sanitizeUrl ( e , { testMode : WebDiscoveryProject . testMode } ) . result !== "safe" ) {
2684- cleanRed . push (
2685- sanitizeUrl ( e , { testMode : WebDiscoveryProject . testMode } )
2686- . safeUrl ,
2687- ) ;
2674+ let safeUrl = sanitizeUrl ( e , {
2675+ testMode : WebDiscoveryProject . testMode ,
2676+ } ) . safeUrl ;
2677+ if ( safeUrl ) {
2678+ cleanRed . push ( safeUrl ) ;
26882679 }
26892680 } ) ;
26902681 msg . payload . red = cleanRed ;
@@ -2772,7 +2763,7 @@ const WebDiscoveryProject = {
27722763 if (
27732764 sanitizeUrl ( msg . payload . r [ eachResult ] . u , {
27742765 testMode : WebDiscoveryProject . testMode ,
2775- } ) . safeUrl
2766+ } ) . result === "safe"
27762767 ) {
27772768 cleanR . push ( msg . payload . r [ eachResult ] ) ;
27782769 }
@@ -2986,7 +2977,10 @@ const WebDiscoveryProject = {
29862977 if ( ! source || source === "openTabs" ) {
29872978 const allOpenPages = await WebDiscoveryProject . getAllOpenPages ( ) ;
29882979 pages = allOpenPages
2989- . map ( ( url ) => ( { url, page_doc : WebDiscoveryProject . state . v [ url ] } ) )
2980+ . map ( ( url ) => ( {
2981+ url,
2982+ page_doc : WebDiscoveryProject . state . v [ url ] ,
2983+ } ) )
29902984 . filter ( ( { url, page_doc } ) => page_doc && isRelevantUrl ( url ) ) ;
29912985 } else if ( source === "unprocessed" ) {
29922986 pages = await new Promise ( ( resolve , reject ) => {
@@ -3458,8 +3452,8 @@ const WebDiscoveryProject = {
34583452
34593453 if (
34603454 queryLikeURL &&
3461- ( ! sanitizeUrl ( query , { testMode : WebDiscoveryProject . testMode } )
3462- . safeUrl ||
3455+ ( sanitizeUrl ( query , { testMode : WebDiscoveryProject . testMode } ) . result !==
3456+ "safe" ||
34633457 WebDiscoveryProject . dropLongURL ( query ) )
34643458 ) {
34653459 logger . debug ( "Query is dangerous" ) ;
@@ -3483,7 +3477,8 @@ const WebDiscoveryProject = {
34833477
34843478 // Check URL is suspicious
34853479 if (
3486- sanitizeUrl ( url , { testMode : WebDiscoveryProject . testMode } ) . result !== "safe"
3480+ sanitizeUrl ( url , { testMode : WebDiscoveryProject . testMode } ) . result !==
3481+ "safe"
34873482 ) {
34883483 logger . debug ( "Url is suspicious" ) ;
34893484 url = "(PROTECTED)" ;
@@ -3856,7 +3851,8 @@ const WebDiscoveryProject = {
38563851 setPrivate = true ;
38573852 logger . debug ( "Setting private because empty page data" ) ;
38583853 } else if (
3859- sanitizeUrl ( url , { testMode : WebDiscoveryProject . testMode } ) . result !== "safe"
3854+ sanitizeUrl ( url , { testMode : WebDiscoveryProject . testMode } )
3855+ . result !== "safe"
38603856 ) {
38613857 // if the url looks private already add it already as checked and private
38623858 let reason = "susp. url" ;
0 commit comments