Skip to content
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

Unable to handle escaped full URLs #29

Open
JeffCleverley opened this issue Jun 8, 2021 · 0 comments
Open

Unable to handle escaped full URLs #29

JeffCleverley opened this issue Jun 8, 2021 · 0 comments

Comments

@JeffCleverley
Copy link

JeffCleverley commented Jun 8, 2021

One of the primary use cases of this would be to rewrite domain urls in the db from http to https

I see you have several tickets on this:

#3
#2
#1

This tool covers:

http://example.com -> https://example.com

but is unable to handle the escaped variants:

http:\/\/example.com -> https:\/\/example.com

Re using delimiters for things like swapping domains:

/example.com -> /newdomain.com

And that would cover most use cases, swapping domains, filepaths etc

But none of this works for swapping http version of domain url to https version of domain url and compensating for escaped urls which are quite commonly found in WP databases.

If you try to pass in the string including escaped slashes, the tool autoescapes these and targets the wrong string instead:

root@may31-devbeta-jeff-buildtest:~# echo "input:"; cat test.sql && cat test.sql | go-search-replace http:\/\/example.com https:\/\/example.com >totest.sql; echo "output:" && cat totest.sql
input:
http://example.com
http:\/\/example.com
output:
https://example.com
http:\/\/example.com

See this has been rewritten instead:

http://example.com -> https://example.com 

And the string with the escaped url is untouched.

This is similar behaviour to interconnectit search-replace, but with that tool you can escape the backslashes like so on the inputs....

So to target escaped urls with interconnectit tool you use:

http:\\\/\/example.com https:\\\/\/example.com

But that doesn't work here:

root@may31-devbeta-jeff-buildtest:~# echo "input:"; cat test.sql && cat test.sql | go-search-replace http:\\\/\/example.com https:\\\/\/example.com >totest.sql; echo "output:" && cat totest.sql
input:
http://example.com
http:\/\/example.com
Invalid <from> URL, minimum length is 4
output:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant