-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: override socket.url with patched.url for all imports #25
Conversation
76fd29a
to
8c18263
Compare
related to #26 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Starting to come to shape; testing and regression issues currently.
plugin/testdata/patched_url_test.lua
Outdated
}, | ||
}, | ||
}, | ||
},} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This schema needs more for the test; url
is never used so there is no validation happening here. The current field uuid
has no value for url
. Create a custom_validator function to verify that url.parse(<a-url-field>)
is working as expected:
<url> ::= <scheme>://<authority>/<path>;<params>?<query>#<fragment>
<authority> ::= <userinfo>@<host>:<port>
<userinfo> ::= <user>[:<password>]
<path> :: = {<segment>/}<segment>
You will want to check:
- scheme
- authority
- userinfo
- user
- password
- host
- port
- path
- params
- query
- fragment
This test could also be extended to validated patched.url
as well in the validator that way we are ensuring backwards compatibility through a regression.
plugin/validator_test.go
Outdated
pluginName, err := v.LoadSchema(string(schema)) | ||
assert.Equal(t, "patched-url-test", pluginName) | ||
assert.Nil(t, err) | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See comment in test schema; we need to increase the surface area of this test.
patches/lua-tree.patch
Outdated
- | ||
-return _M | ||
+return require("patched.url") | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't done so yet, but did you ensure the lua-tree.patch
is still working correctly?
d8b0c74
to
ad9d9de
Compare
4c3740f
to
6104892
Compare
@mikefero patch file is correct now, tests passing. |
6104892
to
4edd380
Compare
patches/lua-tree.patch
Outdated
lua-tree/share/lua/5.1/socket/url.lua | ||
- override all imports of socket.url by returning patched.url | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Duplicated at the bottom; we can remove this.
lua-tree/share/lua/5.1/socket/url.lua | |
- override all imports of socket.url by returning patched.url |
@@ -72,6 +69,9 @@ tools/sandbox.lua | |||
- set configuration.enabled to true | |||
- set configuration.sandbox_enabled to true | |||
|
|||
lua-tree/share/lua/5.1/socket/url.lua |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
super duper nit: between each file we are using two newlines
lua-tree/share/lua/5.1/socket/url.lua | |
lua-tree/share/lua/5.1/socket/url.lua |
@omegabytes Let's get #26 in first and then we can rebase this and fix it up; WDYT? |
ed9c6b7
to
f15d88e
Compare
Found one more usage of patched.url in the patch file that needs to be removed: diff --git a/patches/lua-tree.patch b/patches/lua-tree.patch
index 5953b79..eb93b27 100644
--- a/patches/lua-tree.patch
+++ b/patches/lua-tree.patch
@@ -683,15 +683,6 @@ index 08405b8..2b1157d 100644
end
-- function below is more acurate, but invalidates previously accepted uuids and hence causes
-@@ -273,7 +133,7 @@ end
- --end
-
- do
-- local url = require "socket.url"
-+ local url = require "patched.url"
-
- --- URL escape and format key and value
- -- values should be already decoded or the `raw` option should be passed to prevent double-encoding
@@ -508,7 +368,18 @@ do
local floor = math.floor
local max = math.max
|
Updates socket.lua to return patched/url.lua so that imports of socket.url are overridden to implement patched.url instead. Prior to this change, plugins using socket.url would need to be manually patched in order to function. By overriding the import, we ensure that custom plugins using socket.url work out-of-the-box.
f15d88e
to
d5dcad5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work!!!
Updates socket.lua to return patched/url.lua so that imports of socket.url are overridden to implement patched.url instead.
Prior to this change, plugins using socket.url would need to be manually patched in order to function. By overriding the import, we ensure that custom plugins using socket.url work out-of-the-box.
Adds a test specifically for the socket.url <-> patched.url swap, and updates the diff in
lua-tree.patch
to reflect accurate diff.Hold until after #27