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

Allow includes in feature templates #7020

Merged
merged 5 commits into from
Feb 27, 2024

Conversation

geographika
Copy link
Member

Fix for #6113.

The issue was that [feature] tags are only processed within a [resultset] tag. If included templates don't contain the [resultset] tag the template content is left as a raw string.
When processing [resultset] the code searches through the file for the closing [resultset] tag and gets the content inbetween, without processing [include] tags.
This pull request adds a call to processIncludeTag within processResultSetTag which resolves the issue.

In addition several typos were corrected (as there was quite a bit of time debugging this file to find the issue). Sorry this makes the actual code changes harder to review.

In the end the only required code changes were adding the following, and moving processIncludeTag higher in the file to ensure it was checked:

    /* process any includes within the resultset tag */
    if (processIncludeTag(mapserv, &tag, stream, 0) != MS_SUCCESS) {
      msFreeHashTable(tagArgs);
      return (MS_FAILURE);
    }

There was also a couple of (existing) memory leaks in the case where templates were missing that have been fixed. These were highlighted by the Address Sanitizer CI when new tests were added.
This pull request includes test files to check the issues reported in #6113 - including a JSON example of stripping the last comma when using includes.

One minor (again I believe existing) issue, is that the templates write to a stream, so if errors are encountered after output has been sent then any template text has already been written.
This leads to slightly messed up error responses - such as in the test result template_test005.html

This template tests a missing feature template
Content-Type: text/html

<HTML>
<HEAD><TITLE>MapServer Message</TITLE></HEAD>
<BODY BGCOLOR="#FFFFFF">
processIncludeTag(): Unable to access file. missing.tmpl
</BODY></HTML>

As this error only occurs when templates are missing it will probably only be seen by the developers of a system rather than users.

@jmckenna jmckenna added this to the 8.2.0 Release milestone Feb 1, 2024
@rouault
Copy link
Contributor

rouault commented Feb 26, 2024

@geographika is this good to merge?

@geographika
Copy link
Member Author

@geographika is this good to merge?

Yes, all good from my side.

@geographika geographika merged commit 6e71c56 into MapServer:main Feb 27, 2024
11 checks passed
@geographika geographika deleted the template-includes branch February 27, 2024 10:59
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

Successfully merging this pull request may close these issues.

None yet

3 participants