northernbeacheswebsites / wp-custom-admin-interface

0 stars 0 forks source link

Issue with Malformed URI Handling #1

Open nu-ad opened 4 weeks ago

nu-ad commented 4 weeks ago

Issue summary:

The WP Custom Admin Interface plugin fails to show the menu to edit in the "Edit Admin Menu" tab. The console logs indicate an issue with malformed URIs during the decoding process.

Console Error:

Uncaught URIError: URI malformed
    at decodeURIComponent (<anonymous>)
    at renderAdminMenuManager (options-page-admin-menu.js?ver=7.36:223:54)
    at HTMLDocument.<anonymous> (options-page-admin-menu.js?ver=7.36:242:5)
    at e (load-scripts.php?c=1&load%5Bchunk_0%5D=jquery-core,jquery-migrate,utils,wp-polyfill-inert,regenerator-runtime,wp-polyfill,wp-hooks&ver=6.5.4:2:27028)
    at t (load-scripts.php?c=1&load%5Bchunk_0%5D=jquery-core,jquery-migrate,utils,wp-polyfill-inert,regenerator-runtime,wp-polyfill,wp-hooks&ver=6.5.4:2:27330)

Steps to reproduce:

Navigate to the "Edit Admin Menu" tab in the WP Custom Admin Interface plugin. Observe the console for errors.

Analysis:

The error URIError: URI malformed occurs when decodeURIComponent is called on a string that is not a valid URI. The specific line causing the issue is:

var subLevelMenuThirdValue = decodeURIComponent(subLevelObject[key][3]);

Upon investigation, it was found that some values being passed to decodeURIComponent are not URIs but plain text or HTML, such as:

Upgrade For 80% Off!
<a href="https://wpmudev.com/project/wp-defender/?utm_source=defender&amp;utm_medium=plugin&amp;utm_campaign=defender_submenu_upsell" target="_blank">Upgrade For 80% Off!</a>

In this case the issue is caused by additional submenu promo-link from WPMU Defender plugin.

Proposed solution:

Validation and error handling: Implement a validation function to ensure only valid URIs are passed to decodeURIComponent.

Logging and fallback: Enhance logging to identify problematic data and provide a fallback mechanism for non-URI data.

I hope this is usefull and will allow for a fix.

Regards!

nu-ad commented 4 weeks ago

Sorry, I thought this is an actual git for https://wordpress.org/plugins/wp-custom-admin-interface/