elementor / static-html-output

Static HTML Output Plugin for WordPress
https://statichtmloutput.com
The Unlicense
124 stars 33 forks source link

str_replace uses same value for search and replace parameters #199

Open joyously opened 1 year ago

joyously commented 1 year ago

https://github.com/leonstafford/static-html-output/blob/10cf1af363a07c90d1bec426f7db99f40cadfff9/src/HTMLProcessor.php#L1161-L1166 and https://github.com/leonstafford/static-html-output/blob/10cf1af363a07c90d1bec426f7db99f40cadfff9/src/HTMLProcessor.php#L1185-L1190 both look like a noop, replacing the patterns with the patterns. Should these have a call to getBaseURLRewriteReplacements() instead?

leonstafford commented 1 year ago

Thanks for reporting, @joyously! Been a while since I looked at this.

Are you able to confirm behaviour if you modify as intended?

There should be unit/integration tests covering this code, so will be good to see if/how they fail.

joyously commented 1 year ago

I haven't tried it yet, but suggested it based on logic. Looking more closely at getBaseURLRewriteReplacements(), the patterns don't quite make sense to me.

https://github.com/leonstafford/static-html-output/blob/10cf1af363a07c90d1bec426f7db99f40cadfff9/src/HTMLProcessor.php#L1261-L1277

https://github.com/leonstafford/static-html-output/blob/10cf1af363a07c90d1bec426f7db99f40cadfff9/src/HTMLProcessor.php#L1285-L1301

Putting them side by side, the first three seem okay, but after that, I don't know.

$this->placeholder_url,                              $this->base_url,
addcslashes( $this->placeholder_url, '/' ),          addcslashes( $this->base_url, '/' ),
$this->getProtocolRelativeURL(                       $this->getProtocolRelativeURL(
  $this->placeholder_url                                 $this->base_url
),                                                   ),
$this->getProtocolRelativeURL(                       $this->getProtocolRelativeURL(
  $this->placeholder_url                                 rtrim( $this->base_url, '/' )
),                                                   ),
$this->getProtocolRelativeURL(                       $this->getProtocolRelativeURL(
  $this->placeholder_url . '/'                           $this->base_url . '//'
),                                                   ),
$this->getProtocolRelativeURL(                       $this->getProtocolRelativeURL(
  addcslashes( $this->placeholder_url, '/' )             addcslashes( $this->base_url, '/' )
),                                                   ),