static-html-output icon indicating copy to clipboard operation
static-html-output copied to clipboard

str_replace uses same value for search and replace parameters

Open joyously opened this issue 3 years ago • 2 comments

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?

joyously avatar Oct 01 '22 01:10 joyously

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.

leonstafford avatar Oct 02 '22 13:10 leonstafford

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, '/' )
),                                                   ),

joyously avatar Oct 04 '22 00:10 joyously