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

str_replace uses same value for search and replace parameters #199

Open
joyously opened this issue Oct 1, 2022 · 2 comments
Open

str_replace uses same value for search and replace parameters #199

joyously opened this issue Oct 1, 2022 · 2 comments

Comments

@joyously
Copy link
Contributor

joyously commented Oct 1, 2022

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
Copy link
Contributor

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
Copy link
Contributor Author

joyously commented Oct 4, 2022

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

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

2 participants