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

match_block() function fails to identify HTML blocks with specific innerHTML content #15

Open
attackant opened this issue Oct 18, 2024 · 5 comments
Labels
bug Something isn't working

Comments

@attackant
Copy link
Member

Description of the bug

The match_block() function is not correctly identifying HTML blocks based on their innerHTML content when using the 'with_innerhtml' parameter. This issue specifically affects core/html blocks containing connatix-related content.

Expected behavior:
match_block() should return true for the core/html block containing the connatix div.

Actual behavior:
match_block() returns false, failing to identify the block.

Possible causes:

  1. The Block_InnerHTML validator may not be correctly parsing or comparing the innerHTML content.
  2. The 'with_innerhtml' parameter might not be properly integrated with the core/html block type in the match_block() function.

Steps To Reproduce

  1. Create a WordPress post with a core/html block containing the following content:
  2. Use the following pattern to match the block:
    ['name' => 'core/html', 'with_innerhtml' => 'connatix-']
  3. Call match_block() with this pattern on the post content

Additional Information

  • WordPress version: 6.3
  • match_block plugin version: 3.1
  • A manual check using strpos() on the innerHTML successfully identifies the block, suggesting the issue is specific to the match_block() function or its underlying Block_InnerHTML validator.

Suggested investigation:

  1. Review the implementation of the Block_InnerHTML validator.
  2. Check if there are any filters or actions modifying the block content before it reaches match_block().
  3. Test with different variations of innerHTML content to identify any patterns in the matching failure.

This bug significantly impacts the ability to accurately detect and handle specific types of content blocks, particularly those related to advertising or third-party content integration in this case.

@attackant attackant added the bug Something isn't working label Oct 18, 2024
@dlh01
Copy link
Member

dlh01 commented Oct 21, 2024

@attackant Can you please provide the sample block content? It's mentioned under "Steps To Reproduce" but not included.

@attackant
Copy link
Member Author

It's an empty div <div id="connatix-outstream-video></div> I moved away from using match block in this context, so it's not a time sensitive thing but seemed like the plugin wasn't correctly matching innerhtml in testing.

@dlh01
Copy link
Member

dlh01 commented Oct 21, 2024

Thanks @attackant. I'm not able to immediately replicate that issue. Could you please...

  1. Provide the full serialized block HTML?
  2. Confirm that the block was a top-level block, not an inner block?

@attackant
Copy link
Member Author

  1. <!-- wp:html --><div id="connatix-outstream-video"></div><!-- /wp:html -->
  2. Yes top level.

Might be interacting with some other code in a weird way. I've already moved on to keep on deadline, so feel free to close this if you think it's not a legit bug.

@dlh01
Copy link
Member

dlh01 commented Oct 22, 2024

Thanks. I'm still not able to replicate it, but I don't want to say that it's not a legit bug yet. I think this can stay open in case you or someone else has a similar experience later. If you have any old branches or commits from the project that I could take a look at, feel free to send me those in Slack as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants