com_connect icon indicating copy to clipboard operation
com_connect copied to clipboard

parse $thing in zem_contact_option

Open trenc opened this issue 8 years ago • 5 comments

Another little thingy, I've seen while testing: $thing (and/or label) in zem_contact_option should be parsed by parse().

trenc avatar Mar 09 '17 15:03 trenc

Does it not get parsed here? I thought parse was recursive? Maybe it isn't...

Do you have an example of a select/option form that breaks because it needs parsing? I can then use it to test the functionality and fix it if necessary.

Bloke avatar Mar 09 '17 17:03 Bloke

Hm, weird thing. Here is my example:

<txp:zem_contact_select break="" label="Category">
  <option value="">Choose&hellip;</option>                                                                                                
  <txp:category_list parent="a_category">              
    <txp:zem_contact_option value='<txp:category />'><txp:category title="1" /></txp:zem_contact_option>
  </txp:category_list>                                                          
</txp:zem_contact_select>

As in the code you mentioned it should be parsed. But only the wrapped zem_contact_option is parsed to

<option class="zemOption" value="category_name">&lt;txp:category title=&quot;1&quot; /&gt;</option>

The inner $thing is only handled by txpspecialchars() from the zem_contact_option tag. I've to explicitly parse the $thing in Line 1172 and L1173.

Btw. How do you link to an line number here in GitHub markdown without linking to an issue (#L)?

trenc avatar Mar 10 '17 11:03 trenc

I think, that's the problem. The txpspecialchars() in zem_contact_option is called first and all resulting $thing/$label - as <txp:category title="1" /> in my example - will be txpspecialchars()'d in the first. So there is only a &lt;txp:category title=&quot;1&quot; /&gt; to be parsed.

trenc avatar Mar 15 '17 09:03 trenc

So is the solution to parse($thing) in zem_contact_option somewhere near the top of the function, before $atts is extracted so that the $match gets set correctly? e.g.:

function zem_contact_option($atts, $thing = null)
{
    static $options;
    static $match;

    if ($thing !== null) {
        $thing = parse($thing);
    }

    if ($atts === null) {
      ...

Or will that introduce other oddness?

Bloke avatar Mar 15 '17 09:03 Bloke

Not tested yet, but this will only parse $thing and not $label or $value, isn't it? The resulting html option inner text (option label) can be all other $atts parameters as $label and $value and $thing (see Line1173).

trenc avatar Mar 17 '17 14:03 trenc