Improve URL parser: fix apostrophe in an URL issue
Improve also test tool. Fix #9031, close #9090
This commit is contained in:
parent
47419910f6
commit
2aac88e3b1
@ -3,195 +3,192 @@ local testFiles = {"verifyUrlDetection_1a",
|
|||||||
local URL_INDIC = 8
|
local URL_INDIC = 8
|
||||||
local timerInterval = 10
|
local timerInterval = 10
|
||||||
|
|
||||||
local function verifyUrlDetection()
|
local curPos = 0
|
||||||
|
local task = -1
|
||||||
|
local uFrom = 0
|
||||||
|
local uTo = 0
|
||||||
|
local mFrom = 0
|
||||||
|
local mTo = 0
|
||||||
|
local OKorKO = "OK"
|
||||||
|
local nFile = 1
|
||||||
|
local testResults = {}
|
||||||
|
local outFile = nil
|
||||||
|
|
||||||
local curPos = 0
|
local function Summary()
|
||||||
local task = -1
|
local resLine = ""
|
||||||
local uFrom = 0
|
local i = 1
|
||||||
local uTo = 0
|
while testFiles[i] ~= nil do
|
||||||
local mFrom = 0
|
if testResults[i] == nil then
|
||||||
local mTo = 0
|
testResults[i] = "KO"
|
||||||
local OKorKO = "OK"
|
end
|
||||||
local nFile = 1
|
print(testFiles[i] .. ": " .. testResults[i])
|
||||||
local testResults = {}
|
i = i + 1
|
||||||
local outFile = nil
|
|
||||||
|
|
||||||
local function Summary()
|
|
||||||
local resLine = ""
|
|
||||||
local i = 1
|
|
||||||
while testFiles[i] ~= nil do
|
|
||||||
if testResults[i] == nil then
|
|
||||||
testResults[i] = 'KO'
|
|
||||||
end
|
|
||||||
print(testFiles[i] .. ": " .. testResults[i])
|
|
||||||
i = i + 1
|
|
||||||
end
|
|
||||||
print(resLine)
|
|
||||||
if endNppAfterUrlTest ~= nil then
|
|
||||||
print("good bye")
|
|
||||||
npp:MenuCommand(IDM_FILE_EXIT)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
print(resLine)
|
||||||
|
if endNppAfterUrlTest ~= nil then
|
||||||
|
npp:MenuCommand(IDM_FILE_EXIT)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
local function nextFile()
|
local function nextFile()
|
||||||
local fileAvail = false
|
local fileAvail = false
|
||||||
if outFile ~= nil then
|
if outFile ~= nil then
|
||||||
io.close(outFile)
|
io.close(outFile)
|
||||||
end
|
end
|
||||||
while (not fileAvail) and (testFiles[nFile] ~= nil) do
|
while (not fileAvail) and (testFiles[nFile] ~= nil) do
|
||||||
local fileName = npp:GetNppDirectory() .. "\\..\\Test\\UrlDetection\\" .. testFiles[nFile]
|
local fileName = npp:GetNppDirectory() .. "\\..\\Test\\UrlDetection\\" .. testFiles[nFile]
|
||||||
fileAvail = npp:SwitchToFile(fileName)
|
fileAvail = npp:SwitchToFile(fileName)
|
||||||
if not fileAvail then
|
if not fileAvail then
|
||||||
local f = io.open(fileName,"r")
|
local f = io.open(fileName,"r")
|
||||||
if f~=nil then
|
if f~=nil then
|
||||||
io.close(f)
|
io.close(f)
|
||||||
fileAvail = npp:DoOpen(fileName)
|
fileAvail = npp:DoOpen(fileName)
|
||||||
end
|
|
||||||
end
|
end
|
||||||
-- print("Verifying " .. testFiles[nFile] .. " ...")
|
end
|
||||||
print("Verifying " .. npp:GetFileName() .. " ...")
|
-- print("Verifying " .. testFiles[nFile] .. " ...")
|
||||||
if fileAvail then
|
print("Verifying " .. npp:GetFileName() .. " ...")
|
||||||
local outFileName = fileName .. ".result"
|
if fileAvail then
|
||||||
outFile = io.open(outFileName,"w")
|
local outFileName = fileName .. ".result"
|
||||||
if outFile == nil then
|
outFile = io.open(outFileName,"w")
|
||||||
testResults[nFile] = "KO"
|
if outFile == nil then
|
||||||
print("KO", "Cannot open output file \""..fileName.."\"")
|
|
||||||
print()
|
|
||||||
nFile = nFile + 1;
|
|
||||||
end
|
|
||||||
else
|
|
||||||
testResults[nFile] = "KO"
|
testResults[nFile] = "KO"
|
||||||
print("KO", "Cannot open file \""..fileName.."\"")
|
print("KO", "Cannot open output file \""..fileName.."\"")
|
||||||
print()
|
print()
|
||||||
nFile = nFile + 1;
|
nFile = nFile + 1;
|
||||||
end
|
end
|
||||||
|
else
|
||||||
|
testResults[nFile] = "KO"
|
||||||
|
print("KO", "Cannot open file \""..fileName.."\"")
|
||||||
|
print()
|
||||||
|
nFile = nFile + 1;
|
||||||
end
|
end
|
||||||
return fileAvail
|
|
||||||
end
|
end
|
||||||
|
return fileAvail
|
||||||
|
end
|
||||||
|
|
||||||
local function scrollToNextURL()
|
local function scrollToNextURL()
|
||||||
editor.TargetStart = curPos
|
editor.TargetStart = curPos
|
||||||
|
editor.TargetEnd = editor.Length
|
||||||
|
editor.SearchFlags = SCFIND_REGEXP
|
||||||
|
local iRes = editor:SearchInTarget("^u .+ u$")
|
||||||
|
if iRes >= 0 then
|
||||||
|
uFrom = editor.TargetStart
|
||||||
|
uTo = editor.TargetEnd
|
||||||
|
editor.TargetStart = uFrom
|
||||||
editor.TargetEnd = editor.Length
|
editor.TargetEnd = editor.Length
|
||||||
editor.SearchFlags = SCFIND_REGEXP
|
iRes = editor:SearchInTarget("^m .+ m$")
|
||||||
local iRes = editor:SearchInTarget("^u .+ u$")
|
|
||||||
if iRes >= 0 then
|
if iRes >= 0 then
|
||||||
uFrom = editor.TargetStart
|
mFrom = editor.TargetStart
|
||||||
uTo = editor.TargetEnd
|
mTo = editor.TargetEnd
|
||||||
editor.TargetStart = uFrom
|
local ln1 = editor:LineFromPosition(uFrom)
|
||||||
editor.TargetEnd = editor.Length
|
local ln2 = editor:LineFromPosition(mFrom)
|
||||||
iRes = editor:SearchInTarget("^m .+ m$")
|
if (ln1+1) == ln2 then
|
||||||
if iRes >= 0 then
|
editor:ScrollRange(mTo, uFrom)
|
||||||
mFrom = editor.TargetStart
|
return 1
|
||||||
mTo = editor.TargetEnd
|
|
||||||
local ln1 = editor:LineFromPosition(uFrom)
|
|
||||||
local ln2 = editor:LineFromPosition(mFrom)
|
|
||||||
if (ln1+1) == ln2 then
|
|
||||||
editor:ScrollRange(mTo, uFrom)
|
|
||||||
return 1
|
|
||||||
else
|
|
||||||
editor:GotoPos(mFrom)
|
|
||||||
OKorKO = "KO"
|
|
||||||
print("KO", "Mask line not following immediately after URL line")
|
|
||||||
return -1
|
|
||||||
end
|
|
||||||
else
|
else
|
||||||
|
editor:GotoPos(mFrom)
|
||||||
OKorKO = "KO"
|
OKorKO = "KO"
|
||||||
print ("KO", "Mask line not found")
|
print("KO", "Mask line not following immediately after URL line")
|
||||||
return -1
|
return -1
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
return 0
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local function verifyURL()
|
|
||||||
local mMsk = editor:textrange(mFrom, mTo)
|
|
||||||
editor:GotoPos(uFrom + 2)
|
|
||||||
local uMsk = "m "
|
|
||||||
local limit = mTo - mFrom -- if something goes wrong, edit.CurrentPos may never reach (uTo - 2).
|
|
||||||
while (editor.CurrentPos < uTo - 2) and (limit >= 0) do
|
|
||||||
if editor:IndicatorValueAt(URL_INDIC, editor.CurrentPos) == 0 then
|
|
||||||
uMsk = uMsk .. "0"
|
|
||||||
else
|
|
||||||
uMsk = uMsk .. "1"
|
|
||||||
end
|
|
||||||
editor:CharRight()
|
|
||||||
limit = limit - 1
|
|
||||||
end
|
|
||||||
local Res = 0
|
|
||||||
if limit >= 0 then
|
|
||||||
if editor:textrange(editor.CurrentPos, editor.CurrentPos + 2) == " u" then
|
|
||||||
uMsk = uMsk .. " m"
|
|
||||||
if uMsk == mMsk then
|
|
||||||
outFile:write("OK", "\t", editor:textrange(uFrom, uTo), "\n")
|
|
||||||
Res = 1
|
|
||||||
else
|
|
||||||
outFile:write("KO", "\t", editor:textrange(uFrom, uTo), "\n")
|
|
||||||
outFile:write("ok", "\t", mMsk, "\n")
|
|
||||||
outFile:write("ko", "\t", uMsk, "\n")
|
|
||||||
OKorKO = "KO"
|
|
||||||
Res = 1
|
|
||||||
end
|
|
||||||
end
|
|
||||||
else
|
|
||||||
outFile:write("KO", "\t", "internal error", "\n")
|
|
||||||
OKorKO = "KO"
|
OKorKO = "KO"
|
||||||
|
print ("KO", "Mask line not found")
|
||||||
|
return -1
|
||||||
end
|
end
|
||||||
return Res
|
else
|
||||||
|
return 0
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
local function goForward(timer)
|
local function verifyURL()
|
||||||
if task < 0 then
|
local mMsk = editor:textrange(mFrom, mTo)
|
||||||
task = task + 1
|
editor:GotoPos(uFrom + 2)
|
||||||
if task == 0 then
|
local uMsk = "m "
|
||||||
if not nextFile() then
|
local limit = mTo - mFrom -- if something goes wrong, edit.CurrentPos may never reach (uTo - 2).
|
||||||
npp.StopTimer(timer)
|
while (editor.CurrentPos < uTo - 2) and (limit >= 0) do
|
||||||
Summary()
|
if editor:IndicatorValueAt(URL_INDIC, editor.CurrentPos) == 0 then
|
||||||
end
|
uMsk = uMsk .. "0"
|
||||||
end
|
else
|
||||||
elseif task == 0 then
|
uMsk = uMsk .. "1"
|
||||||
local urlAvail = scrollToNextURL()
|
end
|
||||||
if urlAvail == 1 then
|
editor:CharRight()
|
||||||
task = 1
|
limit = limit - 1
|
||||||
|
end
|
||||||
|
local Res = 0
|
||||||
|
if limit >= 0 then
|
||||||
|
if editor:textrange(editor.CurrentPos, editor.CurrentPos + 2) == " u" then
|
||||||
|
uMsk = uMsk .. " m"
|
||||||
|
if uMsk == mMsk then
|
||||||
|
outFile:write("OK", "\t", editor:textrange(uFrom, uTo), "\n")
|
||||||
|
Res = 1
|
||||||
else
|
else
|
||||||
|
outFile:write("KO", "\t", editor:textrange(uFrom, uTo), "\n")
|
||||||
|
outFile:write("ok", "\t", mMsk, "\n")
|
||||||
|
outFile:write("ko", "\t", uMsk, "\n")
|
||||||
|
print("KO", "\t", editor:textrange(uFrom, uTo))
|
||||||
|
print("ok", "\t", mMsk)
|
||||||
|
print("ko", "\t", uMsk)
|
||||||
|
OKorKO = "KO"
|
||||||
|
Res = 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
else
|
||||||
|
outFile:write("KO", "\t", "internal error", "\n")
|
||||||
|
OKorKO = "KO"
|
||||||
|
end
|
||||||
|
return Res
|
||||||
|
end
|
||||||
|
|
||||||
|
local function goForward(timer)
|
||||||
|
if task < 0 then
|
||||||
|
task = task + 1
|
||||||
|
if task == 0 then
|
||||||
|
if not nextFile() then
|
||||||
npp.StopTimer(timer)
|
npp.StopTimer(timer)
|
||||||
print(OKorKO)
|
Summary()
|
||||||
print()
|
end
|
||||||
testResults[nFile] = OKorKO
|
end
|
||||||
if urlAvail == 0 then
|
elseif task == 0 then
|
||||||
nFile = nFile + 1
|
local urlAvail = scrollToNextURL()
|
||||||
if nextFile() then
|
if urlAvail == 1 then
|
||||||
task = 0
|
task = 1
|
||||||
curPos = 0
|
else
|
||||||
OKorKO = "OK"
|
npp.StopTimer(timer)
|
||||||
npp.StartTimer(timerInterval, goForward)
|
print(OKorKO)
|
||||||
else
|
print()
|
||||||
Summary()
|
testResults[nFile] = OKorKO
|
||||||
end
|
if urlAvail == 0 then
|
||||||
|
nFile = nFile + 1
|
||||||
|
if nextFile() then
|
||||||
|
task = 0
|
||||||
|
curPos = 0
|
||||||
|
OKorKO = "OK"
|
||||||
|
npp.StartTimer(timerInterval, goForward)
|
||||||
else
|
else
|
||||||
Summary()
|
Summary()
|
||||||
end
|
end
|
||||||
end
|
|
||||||
elseif task == 1 then
|
|
||||||
if verifyURL() == 0 then
|
|
||||||
npp.StopTimer(timer)
|
|
||||||
print()
|
|
||||||
Summary()
|
|
||||||
else
|
else
|
||||||
curPos = mTo
|
Summary()
|
||||||
task = 0
|
|
||||||
end
|
end
|
||||||
else
|
end
|
||||||
npp.stopTimer(timer)
|
elseif task == 1 then
|
||||||
print("KO---", "Internal impossibility")
|
if verifyURL() == 0 then
|
||||||
|
npp.StopTimer(timer)
|
||||||
print()
|
print()
|
||||||
Summary()
|
Summary()
|
||||||
|
else
|
||||||
|
curPos = mTo
|
||||||
|
task = 0
|
||||||
end
|
end
|
||||||
|
else
|
||||||
|
npp.stopTimer(timer)
|
||||||
|
print("KO", "Internal impossibility")
|
||||||
|
print()
|
||||||
|
Summary()
|
||||||
end
|
end
|
||||||
|
|
||||||
npp.StartTimer(timerInterval, goForward)
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
npp.ClearConsole()
|
npp.ClearConsole()
|
||||||
verifyUrlDetection()
|
npp.StartTimer(timerInterval, goForward)
|
||||||
|
|
||||||
|
@ -1,26 +1,30 @@
|
|||||||
try {
|
try {
|
||||||
if (Test-Path -Path '..\..\Bin\plugins' -PathType Container)
|
$binDir = '..\..\Bin'
|
||||||
|
$pluginsDir = $binDir + '\plugins'
|
||||||
|
$pluginsSaveDir = $binDir + '\plugins_save'
|
||||||
|
|
||||||
|
if (Test-Path -Path $pluginsDir -PathType Container)
|
||||||
{
|
{
|
||||||
if (Test-Path -Path '..\..\Bin\plugins_save' -PathType Container)
|
if (Test-Path -Path $pluginsSaveDir -PathType Container)
|
||||||
{
|
{
|
||||||
"Backup for plugins directory already exists"
|
"Backup for plugins directory already exists"
|
||||||
exit -1
|
exit -1
|
||||||
}
|
}
|
||||||
"Backing up plugin directory ..."
|
"Backing up plugin directory ..."
|
||||||
Move-Item ..\..\Bin\plugins ..\..\bin\plugins_save
|
Move-Item $pluginsDir $pluginsSaveDir
|
||||||
}
|
}
|
||||||
"Installing Lua plugin for testing ..."
|
"Installing Lua plugin for testing ..."
|
||||||
Copy-Item -Path .\plugins -Destination ..\..\bin -Recurse
|
Copy-Item -Path .\plugins -Destination $binDir -Recurse
|
||||||
|
|
||||||
"Testing ..."
|
"Testing ..."
|
||||||
..\..\bin\notepad++.exe | Out-Null
|
Invoke-Expression ($binDir + "\notepad++.exe | Out-Null")
|
||||||
|
|
||||||
if (Test-Path -Path '..\..\Bin\plugins_save' -PathType Container)
|
if (Test-Path -Path $pluginsSaveDir -PathType Container)
|
||||||
{
|
{
|
||||||
"Removing Lua plugin ..."
|
"Removing Lua plugin ..."
|
||||||
Remove-Item -Path ..\..\Bin\plugins -Recurse -Force
|
Remove-Item -Path $pluginsDir -Recurse -Force
|
||||||
"Restoring plugin directory ..."
|
"Restoring plugin directory ..."
|
||||||
Move-Item ..\..\Bin\plugins_save ..\..\bin\plugins
|
Move-Item $pluginsSaveDir $pluginsDir
|
||||||
}
|
}
|
||||||
|
|
||||||
$expectedRes = Get-Content .\verifyUrlDetection_1a.expected.result
|
$expectedRes = Get-Content .\verifyUrlDetection_1a.expected.result
|
||||||
|
@ -169,6 +169,9 @@ Unwanted trailing character removal:
|
|||||||
u (https://github.com/notepad-plus-plus/notepad-plus-plus) u
|
u (https://github.com/notepad-plus-plus/notepad-plus-plus) u
|
||||||
m 01111111111111111111111111111111111111111111111111111110 m
|
m 01111111111111111111111111111111111111111111111111111110 m
|
||||||
|
|
||||||
|
u [https://github.com/notepad-plus-plus/notepad-plus-plus] u
|
||||||
|
m 01111111111111111111111111111111111111111111111111111110 m
|
||||||
|
|
||||||
u https://github.com/notepad-plus-plus/notepad-plus-plus; u
|
u https://github.com/notepad-plus-plus/notepad-plus-plus; u
|
||||||
m 1111111111111111111111111111111111111111111111111111110 m
|
m 1111111111111111111111111111111111111111111111111111110 m
|
||||||
|
|
||||||
@ -193,6 +196,9 @@ m 01111111111111111111111111111111111111111111110 m
|
|||||||
u (https://en.wikipedia.org/wiki/Saw_2003_film) u
|
u (https://en.wikipedia.org/wiki/Saw_2003_film) u
|
||||||
m 011111111111111111111111111111111111111111110 m
|
m 011111111111111111111111111111111111111111110 m
|
||||||
|
|
||||||
|
u [https://en.wikipedia.org/wiki/Saw_[2003_film]] u
|
||||||
|
m 01111111111111111111111111111111111111111111110 m
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
International characters:
|
International characters:
|
||||||
@ -238,7 +244,224 @@ m 0000001111111111111111111100000000000 m
|
|||||||
u \href{https://ig.com/?query=c761&vars={"id":"0815","first":100}}{click me} u
|
u \href{https://ig.com/?query=c761&vars={"id":"0815","first":100}}{click me} u
|
||||||
m 00000011111111111111111111111111111111111111111111111111111111100000000000 m
|
m 00000011111111111111111111111111111111111111111111111111111111100000000000 m
|
||||||
|
|
||||||
|
========
|
||||||
|
|
||||||
|
Quotation mark
|
||||||
|
- forbidden in name and path (delimiter)
|
||||||
|
- parsed in query part as quoting character,
|
||||||
|
overriding all other quoting characters
|
||||||
|
|
||||||
|
u http://xxx.xxx/xxx"xxx" u
|
||||||
|
m 11111111111111111100000 m
|
||||||
|
|
||||||
|
u http://xxx.xxx/?q="A"+"B"" u
|
||||||
|
m 11111111111111111111111110 m
|
||||||
|
|
||||||
|
u http://xxx.xxx/?q="A'+'B{}`'"" u
|
||||||
|
m 111111111111111111111111111110 m
|
||||||
|
|
||||||
|
========
|
||||||
|
|
||||||
|
Apostrophe
|
||||||
|
- allowed unrestricted in name and path
|
||||||
|
- parsed in query part as quoting character,
|
||||||
|
overriding all other quoting characters
|
||||||
|
|
||||||
|
u https://en.wikipedia.org/wiki/Murphy's_law u
|
||||||
|
m 111111111111111111111111111111111111111111 m
|
||||||
|
|
||||||
|
u http://xxx.xxx/xxx'xxx' u
|
||||||
|
m 11111111111111111111111 m
|
||||||
|
|
||||||
|
u http://xxx.xxx/xxx'xxx'' u
|
||||||
|
m 111111111111111111111111 m
|
||||||
|
|
||||||
|
u http://xxx.xxx/?q='A'+'B'' u
|
||||||
|
m 11111111111111111111111110 m
|
||||||
|
|
||||||
|
u http://xxx.xxx/?q='A'+'B'' u
|
||||||
|
m 11111111111111111111111110 m
|
||||||
|
|
||||||
|
u http://xxx.xxx/?q='A'+'B"{}`'' u
|
||||||
|
m 111111111111111111111111111110 m
|
||||||
|
|
||||||
|
========
|
||||||
|
|
||||||
|
Grave accent
|
||||||
|
- allowed unrestricted in name and path
|
||||||
|
- parsed in query part as quoting character,
|
||||||
|
overriding all other quoting characters
|
||||||
|
|
||||||
|
u http://xxx.xxx/Tom`s_sisters u
|
||||||
|
m 1111111111111111111111111111 m
|
||||||
|
|
||||||
|
u http://xxx.xxx/Tom`s%20sisters` u
|
||||||
|
m 1111111111111111111111111111111 m
|
||||||
|
|
||||||
|
u http://xxx.xxx/Tom`s%20sisters`` u
|
||||||
|
m 11111111111111111111111111111111 m
|
||||||
|
|
||||||
|
u http://xxx.xxx/?q=`A`+`B` u
|
||||||
|
m 1111111111111111111111111 m
|
||||||
|
|
||||||
|
u http://xxx.xxx/?q=`A`+`B`` u
|
||||||
|
m 11111111111111111111111110 m
|
||||||
|
|
||||||
|
u http://xxx.xxx/?q=`A"{}()'`` u
|
||||||
|
m 1111111111111111111111111110 m
|
||||||
|
|
||||||
|
========
|
||||||
|
|
||||||
|
Parentheses
|
||||||
|
- allowed in name and path
|
||||||
|
- closing parenthesis at end of path is removed,
|
||||||
|
if there are no other parentheses in path,
|
||||||
|
except pairing parentheses
|
||||||
|
- parsed in query part as quoting character,
|
||||||
|
overriding all other quoting characters
|
||||||
|
|
||||||
|
- no other parentheses in path, remove last closing parenthesis
|
||||||
|
u http://xxx.xxx/xxx) u
|
||||||
|
m 1111111111111111110 m
|
||||||
|
|
||||||
|
- pairing parentheses in path: remove last closing unpaired parenthesis
|
||||||
|
u http://xxx.xxx/xxx(xxx)) u
|
||||||
|
m 111111111111111111111110 m
|
||||||
|
|
||||||
|
- pairing parentheses in path: remove last closing unpaired parenthesis
|
||||||
|
u http://xxx.xxx/xxx((xxx))) u
|
||||||
|
m 11111111111111111111111110 m
|
||||||
|
|
||||||
|
- pairing parenthesis in path: keep last closing paired parenthesis
|
||||||
|
u http://xxx.xxx/xxx(xxx) u
|
||||||
|
m 11111111111111111111111 m
|
||||||
|
|
||||||
|
- pairing parentheses in path: remove last closing unpaired parenthesis
|
||||||
|
u http://xxx.xxx/xxx()xxx) u
|
||||||
|
m 111111111111111111111110 m
|
||||||
|
|
||||||
|
- arbitrary parentheses in path: keep last closing parenthesis
|
||||||
|
u http://xxx.xxx/xxx)) u
|
||||||
|
m 11111111111111111111 m
|
||||||
|
|
||||||
|
- arbitrary parentheses in path: keep last closing parenthesis
|
||||||
|
u http://xxx.xxx/xxx)(xxx) u
|
||||||
|
m 111111111111111111111111 m
|
||||||
|
|
||||||
|
- arbitrary parentheses in path: keep last closing parenthesis
|
||||||
|
u http://xxx.xxx/xxx)(xxx)) u
|
||||||
|
m 1111111111111111111111111 m
|
||||||
|
|
||||||
|
- arbitrary parentheses in path: keep last closing parenthesis
|
||||||
|
u http://xxx.xxx/xxx((xxx) u
|
||||||
|
m 111111111111111111111111 m
|
||||||
|
|
||||||
|
- arbitrary parentheses in path: keep last closing parenthesis
|
||||||
|
u http://xxx.xxx/xxx)((xxx) u
|
||||||
|
m 1111111111111111111111111 m
|
||||||
|
|
||||||
|
- parentheses in query part: end after last closing quote of query part
|
||||||
|
u http://xxx.xxx/xxx?q=(xxx)) u
|
||||||
|
m 111111111111111111111111110 m
|
||||||
|
|
||||||
|
- parentheses in query part: end after last closing quote of query part
|
||||||
|
u http://xxx.xxx/xxx?q=(xxx)( u
|
||||||
|
m 111111111111111111111111110 m
|
||||||
|
|
||||||
|
- parentheses in query part: end after last closing quote of query part
|
||||||
|
u http://xxx.xxx/xxx?q=(xxx)( u
|
||||||
|
m 111111111111111111111111110 m
|
||||||
|
|
||||||
|
- parentheses in query part: end after last closing quote of query part
|
||||||
|
u http://xxx.xxx/xxx?q=(xxx)&(xxx)( u
|
||||||
|
m 111111111111111111111111111111110 m
|
||||||
|
|
||||||
|
========
|
||||||
|
|
||||||
|
Square brackets
|
||||||
|
- allowed in name and path
|
||||||
|
- closing square bracket at end of path is removed,
|
||||||
|
if there are no other square brackets in path,
|
||||||
|
except pairing square brackets
|
||||||
|
- parsed in query part as quoting characters,
|
||||||
|
overriding all other quoting characters
|
||||||
|
|
||||||
|
- no other square brackets in path, remove last closing square bracket
|
||||||
|
u http://xxx.xxx/xxx] u
|
||||||
|
m 1111111111111111110 m
|
||||||
|
|
||||||
|
- pairing square brackets in path: remove last closing unpaired square bracket
|
||||||
|
u http://xxx.xxx/xxx[xxx]] u
|
||||||
|
m 111111111111111111111110 m
|
||||||
|
|
||||||
|
- pairing square brackets in path: remove last closing unpaired square bracket
|
||||||
|
u http://xxx.xxx/xxx[[xxx]]] u
|
||||||
|
m 11111111111111111111111110 m
|
||||||
|
|
||||||
|
- pairing square brackets in path: keep last closing paired square bracket
|
||||||
|
u http://xxx.xxx/xxx[xxx] u
|
||||||
|
m 11111111111111111111111 m
|
||||||
|
|
||||||
|
- pairing square brackets in path: remove last closing unpaired square bracket
|
||||||
|
u http://xxx.xxx/xxx[]xxx] u
|
||||||
|
m 111111111111111111111110 m
|
||||||
|
|
||||||
|
- arbitrary square brackets in path: keep last closing square bracket
|
||||||
|
u http://xxx.xxx/xxx]] u
|
||||||
|
m 11111111111111111111 m
|
||||||
|
|
||||||
|
- arbitrary square brackets in path: keep last closing square bracket
|
||||||
|
u http://xxx.xxx/xxx][xxx] u
|
||||||
|
m 111111111111111111111111 m
|
||||||
|
|
||||||
|
- arbitrary square brackets in path: keep last closing square bracket
|
||||||
|
u http://xxx.xxx/xxx][xxx]] u
|
||||||
|
m 1111111111111111111111111 m
|
||||||
|
|
||||||
|
- arbitrary square brackets in path: keep last closing square bracket
|
||||||
|
u http://xxx.xxx/xxx[[xxx] u
|
||||||
|
m 111111111111111111111111 m
|
||||||
|
|
||||||
|
- arbitrary square brackets in path: keep last closing square bracket
|
||||||
|
u http://xxx.xxx/xxx][[xxx] u
|
||||||
|
m 1111111111111111111111111 m
|
||||||
|
|
||||||
|
- square brackets in query part: end after last closing quote of query part
|
||||||
|
u http://xxx.xxx/xxx?q=[xxx]] u
|
||||||
|
m 111111111111111111111111110 m
|
||||||
|
|
||||||
|
- square brackets in query part: end after last closing quote of query part
|
||||||
|
u http://xxx.xxx/xxx?q=[xxx][ u
|
||||||
|
m 111111111111111111111111110 m
|
||||||
|
|
||||||
|
- square brackets in query part: end after last closing quote of query part
|
||||||
|
u )http://xxx.xxx/xxx?q=[xxx][ u
|
||||||
|
m 0111111111111111111111111110 m
|
||||||
|
|
||||||
|
- square brackets in query part: end after last closing quote of query part
|
||||||
|
u http://xxx.xxx/xxx?q=[xxx]&[xxx][ u
|
||||||
|
m 111111111111111111111111111111110 m
|
||||||
|
|
||||||
|
========
|
||||||
|
|
||||||
|
Curly brackets
|
||||||
|
- forbidden in name and path, because of LaTeX
|
||||||
|
- parsed in query part as quoting characters,
|
||||||
|
overriding all other quoting characters
|
||||||
|
|
||||||
|
u http://xxx.xxx/xxx{xxx}} u
|
||||||
|
m 111111111111111111000000 m
|
||||||
|
|
||||||
|
u http://xxx.xxx/xxx{xxx} u
|
||||||
|
m 11111111111111111100000 m
|
||||||
|
|
||||||
|
u http://xxx.xxx/xxx?q={xxx}} u
|
||||||
|
m 111111111111111111111111110 m
|
||||||
|
|
||||||
|
u http://xxx.xxx/xxx?q={xxx};{"[]()''`}} u
|
||||||
|
m 11111111111111111111111111111111111110 m
|
||||||
|
|
||||||
|
========
|
||||||
|
|
||||||
Mail:
|
Mail:
|
||||||
|
|
||||||
|
@ -49,6 +49,7 @@ OK u "http://github.com/notepad-plus-plus/notepad-plus-plus" u
|
|||||||
OK u "https://github.com /notepad-plus-plus/notepad-plus-plus" u
|
OK u "https://github.com /notepad-plus-plus/notepad-plus-plus" u
|
||||||
OK u "https://github.com/notepad plus plus/notepad-plus-plus" u
|
OK u "https://github.com/notepad plus plus/notepad-plus-plus" u
|
||||||
OK u (https://github.com/notepad-plus-plus/notepad-plus-plus) u
|
OK u (https://github.com/notepad-plus-plus/notepad-plus-plus) u
|
||||||
|
OK u [https://github.com/notepad-plus-plus/notepad-plus-plus] u
|
||||||
OK u https://github.com/notepad-plus-plus/notepad-plus-plus; u
|
OK u https://github.com/notepad-plus-plus/notepad-plus-plus; u
|
||||||
OK u https://github.com/notepad-plus-plus/notepad-plus-plus? u
|
OK u https://github.com/notepad-plus-plus/notepad-plus-plus? u
|
||||||
OK u https://github.com/notepad-plus-plus/notepad-plus-plus! u
|
OK u https://github.com/notepad-plus-plus/notepad-plus-plus! u
|
||||||
@ -57,6 +58,7 @@ OK u http://github.com/notepad-plus-plus/notepad-plus-plus#fragment u
|
|||||||
OK u (e.g., https://en.wikipedia.org/wiki/Saw_(2003_film))? u
|
OK u (e.g., https://en.wikipedia.org/wiki/Saw_(2003_film))? u
|
||||||
OK u (https://en.wikipedia.org/wiki/Saw_(2003_film)) u
|
OK u (https://en.wikipedia.org/wiki/Saw_(2003_film)) u
|
||||||
OK u (https://en.wikipedia.org/wiki/Saw_2003_film) u
|
OK u (https://en.wikipedia.org/wiki/Saw_2003_film) u
|
||||||
|
OK u [https://en.wikipedia.org/wiki/Saw_[2003_film]] u
|
||||||
OK u https://apache-windows.ru/как-установить-сервер-apache-c-php-mysql-и-phpmyadmin-на-windows/ u
|
OK u https://apache-windows.ru/как-установить-сервер-apache-c-php-mysql-и-phpmyadmin-на-windows/ u
|
||||||
OK u https://www.rnids.rs/национални-домени/регистрација-националних-домена u
|
OK u https://www.rnids.rs/национални-домени/регистрација-националних-домена u
|
||||||
OK u https://www.morfix.co.il/שלום u
|
OK u https://www.morfix.co.il/שלום u
|
||||||
@ -68,6 +70,51 @@ OK u [https://ig.com/?query=c761&vars={"id":"0815","first":100}] u
|
|||||||
OK u "https://ig.com/?query=c761&vars={"id":"0815","first":100}" u
|
OK u "https://ig.com/?query=c761&vars={"id":"0815","first":100}" u
|
||||||
OK u \href{https://weblink.com/}{click me} u
|
OK u \href{https://weblink.com/}{click me} u
|
||||||
OK u \href{https://ig.com/?query=c761&vars={"id":"0815","first":100}}{click me} u
|
OK u \href{https://ig.com/?query=c761&vars={"id":"0815","first":100}}{click me} u
|
||||||
|
OK u http://xxx.xxx/xxx"xxx" u
|
||||||
|
OK u http://xxx.xxx/?q="A"+"B"" u
|
||||||
|
OK u http://xxx.xxx/?q="A'+'B{}`'"" u
|
||||||
|
OK u https://en.wikipedia.org/wiki/Murphy's_law u
|
||||||
|
OK u http://xxx.xxx/xxx'xxx' u
|
||||||
|
OK u http://xxx.xxx/xxx'xxx'' u
|
||||||
|
OK u http://xxx.xxx/?q='A'+'B'' u
|
||||||
|
OK u http://xxx.xxx/?q='A'+'B'' u
|
||||||
|
OK u http://xxx.xxx/?q='A'+'B"{}`'' u
|
||||||
|
OK u http://xxx.xxx/Tom`s_sisters u
|
||||||
|
OK u http://xxx.xxx/Tom`s%20sisters` u
|
||||||
|
OK u http://xxx.xxx/Tom`s%20sisters`` u
|
||||||
|
OK u http://xxx.xxx/?q=`A`+`B` u
|
||||||
|
OK u http://xxx.xxx/?q=`A`+`B`` u
|
||||||
|
OK u http://xxx.xxx/?q=`A"{}()'`` u
|
||||||
|
OK u http://xxx.xxx/xxx) u
|
||||||
|
OK u http://xxx.xxx/xxx(xxx)) u
|
||||||
|
OK u http://xxx.xxx/xxx(xxx) u
|
||||||
|
OK u http://xxx.xxx/xxx()xxx) u
|
||||||
|
OK u http://xxx.xxx/xxx)) u
|
||||||
|
OK u http://xxx.xxx/xxx)(xxx) u
|
||||||
|
OK u http://xxx.xxx/xxx)(xxx)) u
|
||||||
|
OK u http://xxx.xxx/xxx((xxx) u
|
||||||
|
OK u http://xxx.xxx/xxx)((xxx) u
|
||||||
|
OK u http://xxx.xxx/xxx?q=(xxx)) u
|
||||||
|
OK u http://xxx.xxx/xxx?q=(xxx)( u
|
||||||
|
OK u http://xxx.xxx/xxx?q=(xxx)( u
|
||||||
|
OK u http://xxx.xxx/xxx?q=(xxx)&(xxx)( u
|
||||||
|
OK u http://xxx.xxx/xxx] u
|
||||||
|
OK u http://xxx.xxx/xxx[xxx]] u
|
||||||
|
OK u http://xxx.xxx/xxx[xxx] u
|
||||||
|
OK u http://xxx.xxx/xxx[]xxx] u
|
||||||
|
OK u http://xxx.xxx/xxx]] u
|
||||||
|
OK u http://xxx.xxx/xxx][xxx] u
|
||||||
|
OK u http://xxx.xxx/xxx][xxx]] u
|
||||||
|
OK u http://xxx.xxx/xxx[[xxx] u
|
||||||
|
OK u http://xxx.xxx/xxx][[xxx] u
|
||||||
|
OK u http://xxx.xxx/xxx?q=[xxx]] u
|
||||||
|
OK u http://xxx.xxx/xxx?q=[xxx][ u
|
||||||
|
OK u )http://xxx.xxx/xxx?q=[xxx][ u
|
||||||
|
OK u http://xxx.xxx/xxx?q=[xxx]&[xxx][ u
|
||||||
|
OK u http://xxx.xxx/xxx{xxx}} u
|
||||||
|
OK u http://xxx.xxx/xxx{xxx} u
|
||||||
|
OK u http://xxx.xxx/xxx?q={xxx}} u
|
||||||
|
OK u http://xxx.xxx/xxx?q={xxx};{"[]()''`}} u
|
||||||
OK u mailto:don.h@free.fr u
|
OK u mailto:don.h@free.fr u
|
||||||
OK u <don.h@free.fr> u
|
OK u <don.h@free.fr> u
|
||||||
OK u <mailto:don.h@free.fr> u
|
OK u <mailto:don.h@free.fr> u
|
||||||
|
@ -8,18 +8,3 @@ m 0000000000000000 m
|
|||||||
u домhttp://test.com u
|
u домhttp://test.com u
|
||||||
m 000000000000000000 m
|
m 000000000000000000 m
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Apostrophes:
|
|
||||||
|
|
||||||
u https://en.wikipedia.org/wiki/Murphy's_law u
|
|
||||||
m 111111111111111111111111111111111111111111 m
|
|
||||||
|
|
||||||
u http://xxx.xxx/Tom's%20sisters'%20careers u
|
|
||||||
m 11111111111111111111111111111111111111111 m
|
|
||||||
|
|
||||||
u http://xxx.xxx/Tom's%20sisters' u
|
|
||||||
m 1111111111111111111111111111111 m
|
|
||||||
|
|
||||||
u http://xxx.xxx/Tom's%20sisters'' u
|
|
||||||
m 11111111111111111111111111111111 m
|
|
||||||
|
@ -4,15 +4,3 @@ ko m 0111111111111111 m
|
|||||||
KO u домhttp://test.com u
|
KO u домhttp://test.com u
|
||||||
ok m 000000000000000000 m
|
ok m 000000000000000000 m
|
||||||
ko m 000111111111111111 m
|
ko m 000111111111111111 m
|
||||||
KO u https://en.wikipedia.org/wiki/Murphy's_law u
|
|
||||||
ok m 111111111111111111111111111111111111111111 m
|
|
||||||
ko m 111111111111111111111111111111111111000000 m
|
|
||||||
KO u http://xxx.xxx/Tom's%20sisters'%20careers u
|
|
||||||
ok m 11111111111111111111111111111111111111111 m
|
|
||||||
ko m 11111111111111111100000000000000000000000 m
|
|
||||||
KO u http://xxx.xxx/Tom's%20sisters' u
|
|
||||||
ok m 1111111111111111111111111111111 m
|
|
||||||
ko m 1111111111111111110000000000000 m
|
|
||||||
KO u http://xxx.xxx/Tom's%20sisters'' u
|
|
||||||
ok m 11111111111111111111111111111111 m
|
|
||||||
ko m 11111111111111111100000000000000 m
|
|
||||||
|
@ -2600,7 +2600,6 @@ bool isUrlTextChar(TCHAR const c)
|
|||||||
{
|
{
|
||||||
case '"':
|
case '"':
|
||||||
case '#':
|
case '#':
|
||||||
case '\'':
|
|
||||||
case '<':
|
case '<':
|
||||||
case '>':
|
case '>':
|
||||||
case '{':
|
case '{':
|
||||||
@ -2731,11 +2730,21 @@ void scanToUrlEnd(TCHAR *text, int textLen, int start, int* distance)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case sQueryAfterDelimiter:
|
case sQueryAfterDelimiter:
|
||||||
if ((text [p] == '\'') || (text [p] == '"'))
|
if ((text [p] == '\'') || (text [p] == '"') || (text [p] == '`'))
|
||||||
{
|
{
|
||||||
q = text [p];
|
q = text [p];
|
||||||
s = sQueryQuotes;
|
s = sQueryQuotes;
|
||||||
}
|
}
|
||||||
|
else if (text [p] == '(')
|
||||||
|
{
|
||||||
|
q = ')';
|
||||||
|
s = sQueryQuotes;
|
||||||
|
}
|
||||||
|
else if (text [p] == '[')
|
||||||
|
{
|
||||||
|
q = ']';
|
||||||
|
s = sQueryQuotes;
|
||||||
|
}
|
||||||
else if (text [p] == '{')
|
else if (text [p] == '{')
|
||||||
{
|
{
|
||||||
q = '}';
|
q = '}';
|
||||||
@ -2799,43 +2808,28 @@ bool removeUnwantedTrailingCharFromUrl (TCHAR const *text, int* length)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
{ // remove unwanted closing parenthesis
|
{ // remove unwanted closing parenthesis
|
||||||
const TCHAR *closingParenthesis = L")]>";
|
const TCHAR *closingParenthesis = L")]";
|
||||||
const TCHAR *openingParenthesis = L"([<";
|
const TCHAR *openingParenthesis = L"([";
|
||||||
for (int i = 0; closingParenthesis [i]; i++)
|
for (int i = 0; closingParenthesis [i]; i++)
|
||||||
if (text [l] == closingParenthesis [i])
|
if (text [l] == closingParenthesis [i])
|
||||||
{
|
{
|
||||||
int count = 1;
|
int count = 0;
|
||||||
for (int j = l - 1; j >= 0; j--)
|
for (int j = l - 1; j >= 0; j--)
|
||||||
{
|
{
|
||||||
if (text [j] == closingParenthesis [i])
|
if (text [j] == closingParenthesis [i])
|
||||||
count++;
|
count++;
|
||||||
if (text [j] == openingParenthesis [i])
|
if (text [j] == openingParenthesis [i])
|
||||||
count--;
|
if (count > 0)
|
||||||
|
count--;
|
||||||
|
else
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
if (count == 0)
|
if (count != 0)
|
||||||
return false;
|
return false;
|
||||||
*length = l;
|
*length = l;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
{ // remove unwanted quotes
|
|
||||||
const TCHAR *quotes = L"\"'`";
|
|
||||||
for (int i = 0; quotes [i]; i++)
|
|
||||||
{
|
|
||||||
if (text [l] == quotes [i])
|
|
||||||
{
|
|
||||||
int count = 0;
|
|
||||||
for (int j = l - 1; j >= 0; j--)
|
|
||||||
if (text [j] == quotes [i])
|
|
||||||
count++;
|
|
||||||
|
|
||||||
if (count & 1)
|
|
||||||
return false;
|
|
||||||
*length = l;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user