Koha/koha-tmpl/intranet-tmpl/prog/en/includes/cateditor-widgets-marc21.inc
Jonathan Druart dcd1f5d48c Bug 13618: Add html filters to all the variables
Here we go, next step then.
As we did not fix the performance issue when autofiltering
the variables (see bug 20975), the only solution we have is to add the
filters explicitely.

This patch has been autogenerated (using add_html_filters.pl, see next
pathces) and add the html filter to all the variables displayed in the
template.
Exceptions are made (using the new 'raw' TT filter) to the variable we
already listed in the previous versions of this patch.

To test:
- Use t/db_dependent/Koha/Patrons.t to populate your DB with autogenerated
data which contain <script> tags

- Remove them from borrower_debarments.comments (there are allowed here)
update  borrower_debarments set comment="html tags possible here";

- From the interface hit page and try to catch alert box.
If you find one it means you find a possible XSS.
To know where it comes from:
* note the exact URL where you found it
* note the alert box content
* Dump your DB and search for the string in the dump to identify its
location (for instance table.field)

Next:
* Ideally we would like to use the raw filter when it is not necessary
to HTML escape the variables (in big loop for instance)
* Provide a QA script to catch missing filters (we want html, uri, url
or raw, certainly others that I am forgetting now)
* Replace the html filters with uri when needed (!)

Signed-off-by: Owen Leonard <oleonard@myacpl.org>

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
2018-08-17 15:55:05 +00:00

187 lines
8.1 KiB
HTML

<div id="editor-widget-templates" style="display:none">
<div id="widget-leader">
Leader:&nbsp;<span title="Record length (autogenerated)">#####</span>
<select name="f5" title="Record status">
<option value="a">a - Increase in encoding level</option>
<option value="c">c - Corrected or revised</option>
<option value="d">d - Deleted</option>
<option value="n">n - New</option>
<option value="p">p - Increase in encoding level from prepublication</option>
</select>
<select name="f6" title="Type of record">
<option value="a">a - Language material</option>
<option value="c">c - Notated music</option>
<option value="d">d - Manuscript notated music</option>
<option value="e">e - Cartographic material</option>
<option value="f">f - Manuscript cartographic material</option>
<option value="g">g - Projected medium</option>
<option value="i">i - Nonmusical sound recording</option>
<option value="j">j - Musical sound recording</option>
<option value="k">k - Two-dimensional nonprojectable graphic</option>
<option value="m">m - Computer file</option>
<option value="o">o - Kit</option>
<option value="p">p - Mixed materials</option>
<option value="r">r - Three-dimensional artifact or naturally occurring object</option>
<option value="t">t - Manuscript language material</option>
</select>
<select name="f7" title="Bibliographic level">
<option value="a">a - Monographic component part</option>
<option value="b">b - Serial component part</option>
<option value="c">c - Collection</option>
<option value="d">d - Subunit</option>
<option value="i">i - Integrating resource</option>
<option value="m">m - Monograph/item</option>
<option value="s">s - Serial</option>
</select>
<select name="f8" title="Type of control">
<option value=" ">_ - No specific type</option>
<option value="a">a - Archival</option>
</select>
<span title="Encoding (forced Unicode)">a</span>
<span title="Indicator/subfield lengths">22</span>
<span title="Data base address (autogenerated)">#####</span>
<select name="f17" title="Encoding level">
<option value=" ">_ - Full level</option>
<option value="1">1 - Full level, material not examined</option>
<option value="2">2 - Less-than-full level, material not examined</option>
<option value="3">3 - Abbreviated level</option>
<option value="4">4 - Core level</option>
<option value="5">5 - Partial (preliminary) level</option>
<option value="7">7 - Minimal level</option>
<option value="8">8 - Prepublication level</option>
<option value="u">u - Unknown</option>
<option value="z">z - Not applicable</option>
</select>
<select name="f18" title="Descriptive cataloging form">
<option value=" ">_ - Non-ISBD</option>
<option value="a">a - AACR 2</option>
<option value="c">c - ISBD punctuation omitted</option>
<option value="i">i - ISBD punctuation included</option>
<option value="n">n - Non-ISBD punctuation omitted</option>
<option value="u">u - Unknown</option>
</select>
<select name="f19" title="Multipart record resource level">
<option value=" ">_ - Not specified or not applicable</option>
<option value="a">a - Set</option>
<option value="b">b - Part with independent title</option>
<option value="c">c - Part with dependent title</option>
</select>
<span title="Length of directory elements">4500</span>
</div>
</div>
<script>
/**
* Each widget should provide one to three methods:
* init( text ): Returns the DOM node for this widget.
* postCreate( node, mark ): Optional, called once the mark has been created
* and the node shown. Bind event handlers here.
* makeTemplate(): Optional, should return some sane default contents for a
* newly created field/subfield. '<empty>' will be used if this
* method is unset.
*
* Following the Koha convention, control fields are defined as tags with a
* single subfield, '@'.
*/
require( [ 'widget' ], function( Widget ) {
Widget.Register( '000@', {
makeTemplate: function() {
return ' nam a22 7a 4500';
},
init: function() {
var $result = $( '<span class="subfield-widget fixed-widget"></span>' );
return $result[0];
},
postCreate: function() {
// Clear the length and directory start fields; these are unnecessary for MARCXML and will be filled in upon USMARC export
this.setFixed( 0, 5, ' ' );
this.setFixed( 9, 17, 'a22 ' );
this.setFixed( 20, 24, '4500' );
this.insertTemplate( '#widget-leader' );
this.bindFixed( '[name=f5]', 5, 6 );
this.bindFixed( '[name=f6]', 6, 7 );
this.bindFixed( '[name=f7]', 7, 8 );
this.bindFixed( '[name=f8]', 8, 9 );
this.bindFixed( '[name=f17]', 17, 18 );
this.bindFixed( '[name=f18]', 18, 19 );
this.bindFixed( '[name=f19]', 19, 20 );
},
} );
Widget.Register( '005@', {
init: function() {
var $result = $( '<span class="subfield-widget fixed-widget">' + _("Updated: ") + '</span>' );
return $result[0];
},
postCreate: function( node, mark ) {
var parts = this.text.match( /(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})\.(\d)/ );
if ( parts ) {
var dateVal = new Date(
parseInt( parts[1] ), // Year
parseInt( parts[2] ) - 1, // Month (0-11)
parseInt( parts[3] ), // Day
parseInt( parts[4] ), // Hour
parseInt( parts[5] ), // Minute
parseInt( parts[6] ), // Second
parseInt( parts[7] ) * 100 // Millisecond
);
$( this.node ).append( dateVal.toLocaleString() );
} else {
$( this.node ).append( '<span class="hint">' + _("unset") + '</span>' );
}
}
} );
Widget.Register( '006@', {
makeTemplate: function() {
return "a ";
},
init: function() {
var $result = $( '<span class="subfield-widget fixed-widget">' + _("Fixed data:") + '<span class="hint widget-loading">' + _("Loading...") + '</span></span>' );
return $result[0];
},
postCreate: function( node, mark ) {
this.createFromXML( 'marc21/xml/006' );
}
} );
Widget.Register( '007@', {
makeTemplate: function() {
return "a ";
},
init: function() {
var $result = $( '<span class="subfield-widget fixed-widget">' + _("Fixed data:") + '<span class="hint widget-loading">' + _("Loading...") + '</span></span>' );
return $result[0];
},
postCreate: function( node, mark ) {
this.createFromXML( 'marc21/xml/007' );
}
} );
Widget.Register( '008@', {
makeTemplate: function() {
var now = new Date();
return Widget.PadNum( now.getYear() % 100, 2 ) + Widget.PadNum( now.getMonth() + 1, 2 ) + Widget.PadNum( now.getDate(), 2 ) + "b xxu||||| |||| 00| 0 [% DefaultLanguageField008 | html %] d";
},
init: function() {
var $result = $( '<span class="subfield-widget fixed-widget">' + _("Fixed data:") + '<span class="hint widget-loading">' + _("Loading...") + '</span></span>' );
return $result[0];
},
postCreate: function( node, mark ) {
this.createFromXML( 'marc21/xml/008' );
}
} );
} );
</script>