Skip to content

Commit

Permalink
Merge pull request #276 from rcmaehl/0.8.0.0-dev
Browse files Browse the repository at this point in the history
Merge down 0.8.0.0 branch
  • Loading branch information
rcmaehl authored Jun 28, 2023
2 parents 35daa89 + ecc5f2e commit 873ba8e
Show file tree
Hide file tree
Showing 11 changed files with 209 additions and 701 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/MSER.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ jobs:
- name: Download tools
if: steps.cache.outputs.cache-hit != 'true'
run: |
curl -sSfLO https://www.autoitscript.com/cgi-bin/getfile.pl?autoit3/autoit-v3-setup.exe `
-sSfLO https://www.autoitscript.com/cgi-bin/getfile.pl?../autoit3/scite/download/SciTE4AutoIt3.exe `
curl -sSfL https://www.autoitscript.com/cgi-bin/getfile.pl?autoit3/autoit-v3-setup.exe -o autoit-v3-setup.exe `
-sSfL https://www.autoitscript.com/cgi-bin/getfile.pl?../autoit3/scite/download/SciTE4AutoIt3.exe -o SciTE4AutoIt3.exe `
-sSfLO https://www.autoitscript.com/autoit3/scite/download/Au3Stripper.zip
Expand-Archive Au3Stripper.zip "${env:ProgramFiles(x86)}\AutoIt3\SciTE\Au3Stripper"
- name: Install tools
Expand Down
6 changes: 0 additions & 6 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,6 +0,0 @@
[submodule "au3WebDriver"]
path = Includes/au3WebDriver
url = https://github.com/Danp2/au3WebDriver
[submodule "autoit-winhttp"]
path = Includes/autoit-winhttp
url = https://github.com/dragana-r/autoit-winhttp
602 changes: 0 additions & 602 deletions Includes/Json.au3

This file was deleted.

1 change: 1 addition & 0 deletions Includes/ResourcesEx.au3
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <StaticConstants.au3>
#include <WinAPIMisc.au3>
#include <WinAPIRes.au3>
#include <WinAPISysWin.au3>
#include <WindowsConstants.au3>

; Call once the script has ended to tidy up the used resources
Expand Down
14 changes: 14 additions & 0 deletions Includes/_Security.au3
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include-once

#include <Array.au3>
#include <WinAPIProc.au3>
#include <WinAPIShPath.au3>
#include <StringConstants.au3>

Expand Down Expand Up @@ -191,3 +192,16 @@ Func _IsSafeURL(ByRef $sURL)
Return $bSafe

EndFunc

Func _SafeRun($sPath, $sCMDLine = "")

Local $tProcess = DllStructCreate($tagPROCESS_INFORMATION)
Local $tStartup = DllStructCreate($tagSTARTUPINFO)

If $sCMDLine = "" Then
_WinAPI_CreateProcess('', $sPath, 0, 0, 0, $CREATE_NEW_PROCESS_GROUP, 0, 0, $tStartup, $tProcess)
Else
_WinAPI_CreateProcess($sPath, "--MSEdgeRedirect " & $sCMDLine, 0, 0, 0, $CREATE_NEW_PROCESS_GROUP, 0, 0, $tStartup, $tProcess)
EndIf

EndFunc
5 changes: 3 additions & 2 deletions Includes/_Settings.au3
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

#include ".\_Logging.au3"

Global $bDebug = False
Global $bIsAdmin = IsAdmin()
Global $bIsWOW64 = _WinAPI_IsWow64Process()
Global $bIs64Bit = @AutoItX64
Expand Down Expand Up @@ -61,7 +62,7 @@ Func _GetSettingValue($sSetting)
Case $REG_SZ Or $REG_EXPAND_SZ
$vReturn = RegRead("HKLM\SOFTWARE\Policies\Robert Maehl Software\MSEdgeRedirect", $sSetting)
Case $REG_DWORD Or $REG_QWORD
$vReturn = Number(RegRead("HKLM\SOFTWARE\Policies\Robert Maehl Software\MSEdgeRedirect", $sSetting))
$vReturn = Number(RegRead("HKLM\SOFTWARE\Policies\Robert Maehl Software\MSEdgeRedirect", $sSetting))
Case Else
FileWrite($hLogs[$AppFailures], _NowCalc() & " - Invalid Registry Key Type: " & $sSetting & @CRLF)
EndSwitch
Expand Down Expand Up @@ -93,7 +94,7 @@ Func _GetSettingValue($sSetting)
$vReturn = _Bool(IniRead(@ScriptDir & "\MSEdgeRedirect\Settings.ini", "Settings", $sSetting, False))

Case Else
;;;
$vReturn = False

EndSelect

Expand Down
82 changes: 60 additions & 22 deletions Includes/_URLModifications.au3
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ Func _ChangeImageProvider($sURL)
Case "Baidu"
$sURL = "https://image.baidu.com/search/index?tn=baiduimage&word=" & $sURL

Case "Brave"
$sURL = "https://search.brave.com/?ia=images&iax=images&q=" & $sURL

Case "Custom"
$sURL = _GetSettingValue("ImagePath") & $sURL

Expand Down Expand Up @@ -60,9 +63,12 @@ Func _ChangeNewsProvider($sURL)
"|companies" & _
"|medical" & _
"|news(\/crime|\/other|\/politics|\/us)?" & _
"|newsscienceandtechnology" & _
"|research" & _
"|retirement" & _
"|scienceandtech" & _
"|sports" & _
"|techandscience" & _
"|topstories" & _
")\/"

Expand Down Expand Up @@ -105,6 +111,9 @@ Func _ChangeSearchEngine($sURL)
Case "Baidu"
$sURL = "https://www.baidu.com/s?wd=" & $sURL

Case "Brave"
$sURL = "https://search.brave.com/search?q=" & $sURL

Case "Custom"
$sURL = _GetSettingValue("SearchPath") & $sURL

Expand All @@ -120,6 +129,9 @@ Func _ChangeSearchEngine($sURL)
Case "Sogou"
$sURL = "https://www.sogou.com/web?query=" & $sURL

Case "Startpage"
$sURL = "https://www.startpage.com/search?q=" & $sURL

Case "Yahoo"
$sURL = "https://search.yahoo.com/search?p=" & $sURL

Expand Down Expand Up @@ -178,7 +190,7 @@ Func _ChangeWeatherProvider($sURL)
Case StringInStr($sURL, "loc=") ; New Style Weather URL
$vCoords = StringRegExpReplace($sURL, "(?i)(.*)(\?loc=)", "")
$vCoords = StringRegExpReplace($vCoords, "(?i)(?=\&weadegreetype=)(.*)", "")
$vCoords = _UnicodeURLDecode($vCoords)
$vCoords = _WinAPI_UrlUnescape($vCoords)
$vCoords = _Base64Decode($vCoords)
$vCoords = BinaryToString($vCoords)
$vCoords = StringRegExpReplace($vCoords, "(?i){|}", "")
Expand Down Expand Up @@ -283,10 +295,11 @@ Func _RedirectCMDDecode($sCMDLine)
Local $aCMDLine_2D[0][0]

$sCMDLine = StringReplace($sCMDLine, "--edge-redirect", "Method")
If StringInStr($sCMDLine, "https://www.bing.com/search?q=") Then ; #211
If StringInStr($sCMDLine, "://") Then ; #211
$sCMDLine = StringReplace($sCMDLine, "&", "%26")
$sCMDLine = StringReplace($sCMDLine, "/", "%2F")
$sCMDLine = StringReplace($sCMDLine, "=", "%3D")
$sCMDLine = StringReplace($sCMDLine, "URL%3D", "URL=")
$sCMDLine = StringReplace($sCMDLine, "Method%3D", "Method=")
EndIf
$sCMDLine = StringReplace($sCMDLine, "microsoft-edge:?", "&")
Expand All @@ -303,34 +316,59 @@ Func _RedirectCMDDecode($sCMDLine)

EndFunc


; #FUNCTION# ====================================================================================================================
; Name ..........: _UnicodeURLDecode
; Description ...: Tranlates a URL-friendly string to a normal string
; Syntax ........: _UnicodeURLDecode($toDecode)
; Parameters ....: $toDecode - The URL-friendly string to decode
; Syntax ........: _UnicodeURLDecode($sData)
; Parameters ....: $sData - The URL-friendly string to decode
; Return values .: The URL decoded string
; Author ........: nfwu, Dhilip89, rcmaehl
; Modified ......: 10/26/2022
; Remarks .......: Modified from _URLDecode() that only supported non-unicode.
; Remarks .......:
; Related .......:
; Link ..........:
; Example .......: No
; ===============================================================================================================================
Func _UnicodeURLDecode($toDecode)
Local $strChar = "", $iOne, $iTwo
Local $aryHex = StringSplit($toDecode, "")
For $i = 1 To $aryHex[0]
If $aryHex[$i] = "%" Then
$i += 1
$iOne = $aryHex[$i]
$i += 1
$iTwo = $aryHex[$i]
$strChar = $strChar & Chr(Dec($iOne & $iTwo))
Else
$strChar = $strChar & $aryHex[$i]
EndIf
Func _UnicodeURLDecode($sData)
Local $aData = StringSplit(StringReplace($sData,"+"," ",0,1),"%")
$sData = ""
For $i = 2 To $aData[0]
$aData[1] &= Chr(Dec(StringLeft($aData[$i],2))) & StringTrimLeft($aData[$i],2)
Next
Local $Process = StringToBinary(StringReplace($strChar, "+", " "))
Local $DecodedString = BinaryToString($Process, 4)
Return $DecodedString
EndFunc ;==>_UnicodeURLDecode
Return BinaryToString(StringToBinary($aData[1],1),4)
EndFunc

; #FUNCTION# ====================================================================================================================
; Name ..........: _WinAPI_UrlUnescape
; Description ...: Tranlates a URL-friendly string to a normal string
; Syntax ........: _WinAPI_UrlUnescape($sData[, $dFlag])
; Parameters ....: $sURL - The URL-friendly string to decode
; $dFlag - [Optional] WinAPI Function parameters
; Return values .: The URL unescaped string
; Author ........: mistersquirrle, rcmaehl
; Modified ......: 3/27/2023
; Remarks .......: URL_DONT_UNESCAPE_EXTRA_INFO = 0x02000000
; URL_UNESCAPE_AS_UTF8 = 0x00040000 (Win 8+)
; URL_UNESCAPE_INPLACE = 0x00100000
; Related .......:
; Link ..........:
; Example .......: No
; ===============================================================================================================================

Func _WinAPI_UrlUnescape($sUrl, $dFlags = 0x00040000)

; https://learn.microsoft.com/en-us/windows/win32/api/shlwapi/nf-shlwapi-urlunescapew
Local $aUrlUnescape = DllCall("Shlwapi.dll", "long", "UrlUnescapeW", _
"wstr", $sUrl, _ ; PWSTR pszUrl - A pointer to a null-terminated string with the URL
"wstr", "decodedUrl", _ ; PWSTR pszUnescaped - A pointer to a buffer that will receive a null-terminated string that contains the unescaped version of pszURL
"dword*", 1024, _ ; DWORD *pcchUnescaped - The number of characters in the buffer pointed to by pszUnescaped
"dword", $dFlags) ; DWORD dwFlags
If @error Then
; ConsoleWrite('UrlUnescape error: ' & @error & ', LastErr: ' & _WinAPI_GetLastError() & ', LastMsg: ' & _WinAPI_GetLastErrorMessage() & @CRLF)
Return SetError(@error, @extended, 0)
EndIf

If IsArray($aUrlUnescape) Then Return $aUrlUnescape[2]

EndFunc ;==>_WinAPI_UrlUnescape
1 change: 0 additions & 1 deletion Includes/au3WebDriver
Submodule au3WebDriver deleted from 8c802d
1 change: 0 additions & 1 deletion Includes/autoit-winhttp
Submodule autoit-winhttp deleted from e82bc4
Loading

0 comments on commit 873ba8e

Please sign in to comment.