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

parse $thing in zem_contact_option #48

Open
trenc opened this issue Mar 9, 2017 · 5 comments
Open

parse $thing in zem_contact_option #48

trenc opened this issue Mar 9, 2017 · 5 comments

Comments

@trenc
Copy link

trenc commented Mar 9, 2017

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

@Bloke
Copy link
Member

Bloke commented Mar 9, 2017

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.

@trenc
Copy link
Author

trenc commented Mar 10, 2017

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

trenc commented Mar 15, 2017

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.

@Bloke
Copy link
Member

Bloke commented Mar 15, 2017

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?

@trenc
Copy link
Author

trenc commented Mar 17, 2017

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).

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