pods-framework / pods

The Pods Framework is a Content Development Framework for WordPress - It lets you create and extend content types that can be used for any project. Add fields of various types we've built in, or add your own with custom inputs, you have total control.
https://pods.io/
GNU General Public License v2.0
1.06k stars 265 forks source link

Returns in shortcode attributes converted to <br /> #7228

Closed pd-cm closed 3 months ago

pd-cm commented 7 months ago

Description

In this Slack support request, a Pods shortcode WHERE query was failing because there was a return within the WHERE statement.

I do not know if this is an issue with Gutenberg, WordPress core, or something within Pods, but the general idea is that something is converting line breaks to HTML <br/> tags before shortcodes and shortcode attributes are parsed.

The result is a silent failure due to SQL error unless Query Monitor is installed.

Version

3.0.8

Testing Instructions

See the video and pods.json in the Slack thread.

Or write a Pods shortcode which has a WHERE query with a return in it, which should be both valid SQL and a valid attribute, except that the return is converted to HTML before it gets to MySQL.

Screenshots / Screencast

https://github.com/pods-framework/pods/assets/38669929/10af9255-58bd-41b0-b786-5ce86ef06e01

Possible Workaround

Change some content-related filter priorities, or output meaningful SQL errors. A PHP try/catch statement can catch both Error | Exception -- e.g., either a fatal error or thrown exception, returning the message.

Site Health Information

No response

Pods Package

See Slack thread.
sc0ttkclark commented 7 months ago

This is related to WP core itself in how it handles attributes, I’m not sure if there’s a safe way to strip those out without potentially messing with a query that was using the <br/> tags intentionally.

sc0ttkclark commented 7 months ago

I don't think line breaks were ever intended to be used in shortcode attributes themselves but it's for sure never been supported in Pods shortcodes in the past.