GUI: result list paragraph format: avoid problems with input like <table style: "width: 100%">

- Document the fact that literal % characters need to be quoted as %%
 - Preserve the original input if the % substitution has no defined target.
This commit is contained in:
Jean-Francois Dockes 2022-07-02 09:07:53 +02:00
parent 3560b9e3b0
commit 6c777f8fe7
3 changed files with 58 additions and 47 deletions

View File

@ -4989,9 +4989,22 @@ fs.inotify.max_user_watches=32768
</div>
</div>
</div>
<p>This is an arbitrary HTML string where the
following printf-like <code class="literal">%</code>
substitutions will be performed:</p>
<p>This is an arbitrary HTML string which will be
transformed by printf-like <code class=
"literal">%</code> substitutions to show the
results.</p>
<div class="note" style=
"margin-left: 0.5in; margin-right: 0.5in;">
<h3 class="title">Note</h3>
<p>Any literal <code class="literal">%</code>
character in the input must be quoted as
<code class="literal">%%</code>. E.g. <code class=
"literal">&lt;table style="width: 100%;"&gt;</code>
should be entered as <code class=
"literal">&lt;table style="width:
100%%;"&gt;</code>.</p>
</div>
<p>The following substitutions will be performed:</p>
<div class="itemizedlist">
<ul class="itemizedlist" style=
"list-style-type: disc;">
@ -5054,6 +5067,24 @@ fs.inotify.max_user_watches=32768
</li>
</ul>
</div>
<p>In addition to the predefined values above, all
strings like <code class=
"literal">%(fieldname)</code> will be replaced by the
value of the field named <code class=
"literal">fieldname</code> for this document. Only
stored fields can be accessed in this way, the value
of indexed but not stored fields is not known at this
point in the search process (see <a class="link"
href="#RCL.PROGRAM.FIELDS" title=
"4.2.&nbsp;Field data processing">field
configuration</a>). There are currently very few
fields stored by default, apart from the values above
(only <code class="literal">author</code> and
<code class="literal">filename</code>), so this
feature will need some custom local configuration to
be useful. An example candidate would be the
<code class="literal">recipient</code> field which is
generated by the message input handlers.</p>
<p>The format of the Preview, Edit, and Snippets
links is <code class="literal">&lt;a
href="P%N"&gt;</code>, <code class="literal">&lt;a
@ -5078,24 +5109,6 @@ fs.inotify.max_user_watches=32768
"link" href="#RCL.SEARCH.GUI.RUNSCRIPT" title=
"3.2.5.&nbsp;Unix-like systems: running arbitrary commands on result files">
section about defining scripts</a>.</p>
<p>In addition to the predefined values above, all
strings like <code class=
"literal">%(fieldname)</code> will be replaced by the
value of the field named <code class=
"literal">fieldname</code> for this document. Only
stored fields can be accessed in this way, the value
of indexed but not stored fields is not known at this
point in the search process (see <a class="link"
href="#RCL.PROGRAM.FIELDS" title=
"4.2.&nbsp;Field data processing">field
configuration</a>). There are currently very few
fields stored by default, apart from the values above
(only <code class="literal">author</code> and
<code class="literal">filename</code>), so this
feature will need some custom local configuration to
be useful. An example candidate would be the
<code class="literal">recipient</code> field which is
generated by the message input handlers.</p>
<p>The default value for the paragraph format string
is:</p>
<pre class="screen">

View File

@ -3667,9 +3667,13 @@ fs.inotify.max_user_watches=32768
<sect4 id="RCL.SEARCH.GUI.CUSTOM.RESLIST.PARA">
<title>The paragraph format</title>
<para>This is an arbitrary HTML string where the following printf-like
<literal>%</literal> substitutions will be performed:
<para>This is an arbitrary HTML string which will be transformed by printf-like
<literal>%</literal> substitutions to show the results.
<note><para>Any literal <literal>%</literal> character in the input
must be quoted as <literal>%%</literal>. E.g. <literal>&lt;table style="width:
100%;"&gt;</literal> should be entered as
<literal>&lt;table style="width: 100%%;"&gt;</literal>.</para></note>
The following substitutions will be performed:
<itemizedlist>
<listitem>
<formalpara><title>%A</title><para>Abstract</para></formalpara>
@ -3719,6 +3723,17 @@ fs.inotify.max_user_watches=32768
</listitem>
</itemizedlist>
<para>In addition to the predefined values above, all strings
like <literal>%(fieldname)</literal> will be replaced by the value of the field
named <literal>fieldname</literal> for this document. Only stored fields can be accessed
in this way, the value of indexed but not stored fields is not known at this point in
the search process (see <link linkend="RCL.PROGRAM.FIELDS">field
configuration</link>). There are currently very few fields stored by default, apart from
the values above (only <literal>author</literal> and <literal>filename</literal>), so
this feature will need some custom local configuration to be useful. An example
candidate would be the <literal>recipient</literal> field which is generated by the
message input handlers.</para>
The format of the Preview, Edit, and Snippets links is
<literal>&lt;a href="P%N"&gt;</literal>,
<literal>&lt;a href="E%N"&gt;</literal>
@ -3740,20 +3755,6 @@ fs.inotify.max_user_watches=32768
embedded, the script will be started on the top-level parent).
See the <link linkend="RCL.SEARCH.GUI.RUNSCRIPT">section about defining scripts</link>.</para>
<para>In addition to the predefined values above, all strings
like <literal>%(fieldname)</literal> will be replaced by the
value of the field named <literal>fieldname</literal> for this
document. Only stored fields can be accessed in this way, the
value of indexed but not stored fields is not known at this
point in the search process
(see <link linkend="RCL.PROGRAM.FIELDS">field configuration</link>). There are currently very few fields
stored by default, apart from the values above
(only <literal>author</literal>
and <literal>filename</literal>), so this feature will need
some custom local configuration to be useful. An example
candidate would be the <literal>recipient</literal> field
which is generated by the message input handlers.</para>
<para>The default value for the paragraph format string is:
<screen><![CDATA[
"<table class=\"respar\">\n"
@ -7103,7 +7104,7 @@ other = rclcat:other
<para>The right side of each assignment holds a command to be
executed for opening the file. The following substitutions are
performed:</para>
<itemizedlist>
<listitem>
<formalpara><title>%D</title>

View File

@ -611,12 +611,11 @@ bool pcSubst(const string& in, string& out, const map<char, string>& subs)
out += '%';
continue;
}
map<char, string>::const_iterator tr;
if ((tr = subs.find(*it)) != subs.end()) {
auto tr = subs.find(*it);
if (tr != subs.end()) {
out += tr->second;
} else {
// We used to do "out += *it;" here but this does not make
// sense
out += std::string("%") + *it;
}
} else {
out += *it;
@ -648,7 +647,7 @@ bool pcSubst(const string& in, string& out, const map<string, string>& subs)
string::size_type j = in.find_first_of(')', i);
if (j == string::npos) {
// ??concatenate remaining part and stop
out += in.substr(i - 2);
out += std::string("%") + in.substr(i - 2);
break;
}
key = in.substr(i, j - i);
@ -660,9 +659,7 @@ bool pcSubst(const string& in, string& out, const map<string, string>& subs)
if ((tr = subs.find(key)) != subs.end()) {
out += tr->second;
} else {
// Substitute to nothing, that's the reasonable thing to do
// instead of keeping the %(key)
// out += key.size()==1? key : string("(") + key + string(")");
out += std::string("%") + (key.size()==1? key : string("(") + key + string(")"));
}
} else {
out += in[i];