Incorrect regex for HTTP to HTTPS?
-
In the file
pardot-plugin-class.php
on line 635 (version 1.4) there’s a regex for transforming non-secure URLs into secure ones but it is breaking for us. The last pattern is(\/\S*)?
which is an optional group that’s a forward slash followed by zero or more non-space characters but since we’re parsing HTML I think we’d want single or double-quote terminator in there, too. We changed it to[^\"']*
which is zero or more characters that aren’t one of the two quotes. (Technically you’d want to balance quotes but I just needed to get this working.)Our full line is (we also disabled capturing on the first group)L
$reg_exUrl = "/(?:http|https|ftp|ftps)\:\/\/[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}[^\"']*/";
I think the bigger problem stems from our HTML including some fully-qualified domains for CSS/JS and the original code wasn’t intended for this.
- The topic ‘Incorrect regex for HTTP to HTTPS?’ is closed to new replies.