interconnectit / Search-Replace-DB

This script was made to aid the process of migrating PHP and MySQL based websites. Works with most common CMSes.
https://interconnectit.com/products/search-and-replace-for-wordpress-databases/
GNU General Public License v3.0
4k stars 855 forks source link

The search does not seem to be escaped #210

Closed mrb2590 closed 4 years ago

mrb2590 commented 7 years ago

FYI

There is some JSON in my database which has some URLs I was trying to replace. The URL is stored in JSON like so: {url: "http:\/\/www.example.com"} Searching for http://example.com did not work and also searching for http:\/\/www.example.com did not work.

What worked was searching for http:\\\/\\\/www.example.com

kg00 commented 7 years ago

First, thank you for this amazing script. Been using the old version for years and did not know youhad it updated. The 3.x version is really nice.

Confirming the problem described by mrb2590 above and adding that there is also a problem with the replace part when escaping Searching for images\/Pictures\/ did not work but searching for images\\/Pictures\\/ works fine.

But replacing images\\/Pictures\\/ with images\\/whatever\\/ does not show any changes when Viewing changes in the popup. There it still shows images\\/Pictures\\/ but looking in the actual table, the changes was made as they should.

stompro commented 6 years ago

I'm not sure if this is the same issue, but I found that it isn't possible to preview results when you do a non regex search for something like url(http://newlive.example.org/

It looks like the highlighting fails because it tries to use the search term in a regex with no escaping, so the preview never shows.

(index):1345 Uncaught SyntaxError: Invalid regular expression: /url(http://newlive.example.org//: Unterminated group at new RegExp () at HTMLAnchorElement.changes_overlay ((index):1345) at HTMLAnchorElement.dispatch ((index):725) at HTMLAnchorElement.v.handle ((index):725) changes_overlay @ (index):1345 dispatch @ (index):725 v.handle @ (index):725

gianluigi-icit commented 4 years ago

I finally checked this one, I could change the code and make life easier but this change could potentially break some other user's script.

Until we completely refactor this tool, I close this one and #215 .