diff --git a/INSTALL b/INSTALL index 23e5f25..84d9d84 100644 --- a/INSTALL +++ b/INSTALL @@ -1,3 +1,38 @@ +Ctemplate-Specific Install Notes +================================ + +This code should work on any modern C++ system. It has been tested on +the following systems: + FreeBSD 6.0 + Linux Fedora Core 3 + Linux Fedora Core 4 + Linux Fedora Core 5 + Linux Fedora Core 6 + Linux RedHat 9 + Linux Ubuntu 6.06.1 + Mac OS X 10.3.9 (Panther) + Mac OS X 10.4.8 (Tiger) + Solaris 10 (x86) + Windows XP, Visual Studio 2003 (VC++7.1) + Windows XP, Visual Studio 2005 (VC++8) + +The only known problem is with Mac OS X 10.3.9 (Panther), which may +have problems with the export-symbols optimization this library does +to limit its exposed API. If you have problems compiling that seem to +involve nmedit, the solution is to edit the Makefile and remove all +instances of + -export-symbols-regex $(CTEMPLATE_TESTING_SYMBOLS) +Just remove that string exactly. After that, code should build. + +For Solaris 10 6/06, we have tested only with gcc (not the Sun +compiler). To get this to work, and to work around a bug in Solaris, +install as follows: + % PATH=${PATH}:/usr/sfw/bin/:/usr/ccs/bin ./configure LDFLAGS="-Lsrc/solaris -lrt" + % PATH=${PATH}:/usr/sfw/bin/:/usr/ccs/bin make + +See README.windows for installation instructions for Windows. + + Installation Instructions ************************* diff --git a/Makefile.am b/Makefile.am index 2007ddc..c90db09 100644 --- a/Makefile.am +++ b/Makefile.am @@ -48,7 +48,7 @@ docdir = $(prefix)/share/doc/$(PACKAGE)-$(VERSION) ## This is for HTML and other documentation you want to install. ## Add your documentation files (in doc/) in addition to these ## top-level boilerplate files. Also add a TODO file if you have one. -dist_doc_DATA = AUTHORS COPYING ChangeLog INSTALL NEWS README README.windows \ +dist_doc_DATA = AUTHORS COPYING ChangeLog INSTALL NEWS README README_windows.txt \ doc/designstyle.css doc/index.html \ doc/howto.html doc/tips.html doc/example.html doc/auto_escape.html \ doc/xss_resources.html diff --git a/Makefile.in b/Makefile.in index 371a75b..e6c5f7f 100644 --- a/Makefile.in +++ b/Makefile.in @@ -673,7 +673,7 @@ noinst_HEADERS = \ src/ctemplate/template_namelist.h.in \ src/ctemplate/per_expand_data.h.in -dist_doc_DATA = AUTHORS COPYING ChangeLog INSTALL NEWS README README.windows \ +dist_doc_DATA = AUTHORS COPYING ChangeLog INSTALL NEWS README README_windows.txt \ doc/designstyle.css doc/index.html \ doc/howto.html doc/tips.html doc/example.html doc/auto_escape.html \ doc/xss_resources.html diff --git a/NEWS b/NEWS index e69de29..c10ae04 100644 --- a/NEWS +++ b/NEWS @@ -0,0 +1,146 @@ +=== 20 April 2010 == + +I've just released ctemplate 0.97. This change consists primarily of +a significant change to the API: the addition of the `TemplateCache` +class, combined with deprecation of the `Template` class. + +`TemplateCache` is a class that holds a collection of templates; this +concept always existed in ctemplate, but was not previously exposed. +Many static methods of the `Template` class, such as +`ReloadAllIfChanged()`, have become methods on `TemplateCache` instead +(the `Template` methods have been retained for backwards +compatibility.) Other methods, such as `Expand()`, have become free +functions. In fact, the entire `Template` class has been deprecated. + +The deprecation of `Template` calls for changes in all clients of the +template code -- you can see in the example at the top of this page +how the code has changed from `Template* tpl = +ctemplate::Template::GetTemplate("example.tpl", +ctemplate::DO_NOT_STRIP); tpl->Expand(&output, &dict);` to +`ctemplate::ExpandTemplate("example.tpl", ctemplate::DO_NOT_STRIP, +&dict, &output);`. These changes will make the code simpler and more +thread-safe. + +Old code should continue to work -- the `Template` class remains -- +but new code should use the new API, and old code should transition as +convenient. One old API method is intrinsically thread-unsafe, and +should be prioritized to change: `tpl->ReloadIfChanged` should change +to `ctemplate::Template::ReloadAllIfChanged()`. Note this is a +semantic change: all templates are now reloaded, rather than just one. +However, since templates are reloaded lazily, and only if they've +changed on disk, I'm hopeful it will always be a reasonable change to +make. + +To go along with these changes, the documentation has been almost +entirely revamped and made more accessible. Obscure ctemplate +features have been excised from the user's guide and moved into a +separate reference document. The new API is fully documented, +including new flexibility around reloading templates, made available +by the introduction of `TemplateCache`. + +There are some more minor changes as well, such as the addition of +#include guards in the auto-generated .tpl.h files, to make it safe to +multiply-include them. I've also been continuing the portability +work: ctemplate should now work under Cygwin and MinGW. A full list +of changes is available in the +[http://google-ctemplate.googlecode.com/svn/tags/ctemplate-0.97/ChangeLog +ChangeLog]. + +I know I've said this before, but I don't expect major API changes +before the 1.0 release. The most significant changes I expect to see +are the potential removal of some of the 'forwarding' methods in the +(deprecated) `Template` class. + +=== 12 June 2009 == + +I've just released ctemplate 0.95. This is entirely an API cleanup +release. Actually, relatively little of the API proper has changed: +`StringToTemplate` no longer takes an autoescape-context arg (instead +you specify this as part of the template-string, using the +`AUTOESCAPE` pragma). A few obsolete constructs have gone away, such +as the `TemplateFromString` class and +`TemplateDictionary::html_escape` and friends (just use the top-level +`html_escape`). See the +[http://google-ctemplate.googlecode.com/svn/tags/ctemplate-0.95/ChangeLog +ChangeLog] for a full list of these changes. + +The biggest change is a renaming: the default namespace is now +`ctemplate` rather than `google`, and the include directory is +`ctemplate` rather than `google`. Other namespaces, such as +`template_modifiers`, have gone away. + +All these changes will require you to modify your old code to get it +working with ctemplate 0.95. I've written a +[http://google-ctemplate.googlecode.com/svn/trunk/contrib/convert_to_95.pl +script] to help you do that. Please open an +[http://code.google.com/p/google-ctemplate/issues/list issue] if you +see a problem with the script. I've tested it, but not as widely as +I'd like. Also note the script will not be perfect for more complex +constructs, which you will have to clean up by hand. + +I hope (expect) the API is now stable, and we won't see any more such +changes before ctemplate 1.0. I tried to isolate them all in this +release; except for the API changes, this release should behave +identically to ctemplate 0.94. + +=== 7 May 2009 === + +I've just released ctemplate 0.94. A few new features have been +added, such as the ability to expand a template into your own custom +`ExpandEmitter` instance, and the ability to hook the annotation +system (typically used for debugging). You can now remove strings +from the template cache in addition to adding them. Also, there +continues to be a trickle of new modifiers, in this case a modifier +for URL's in a CSS context. + +However, the most invasive changes were made for speed reasons. The +biggest is that (almost) all `TemplateDictionary` allocations are now +done on the arena -- this includes allocations by the STL classes +inside the dictionary. This allows us to free all the memory at once, +rather than item by item, and has yielded a 3-4% speed improvement in +our tests. I've combined this with a `small_map` class that stores +items in a vector instead of a hash-map until we get to 3 or 4 items; +this gives another speed increase in the (common) case a template has +only a few sections or includes. + +I also changed the hashing code to use +[http://murmurhash.googlepages.com/ MurmurHash] everywhere, rather +than the string hash function built into the STL library. This should +be faster. + +All these changes should not be outwardly visible, but they do use +more advanced features of C++ than ctemplate has to date. This may +result in some problems compiling, or conceivably when running. If +you see any, please file an +[http://code.google.com/p/google-ctemplate/issues/list issue report]. + +You can see a full list of changes on the +[http://google-ctemplate.googlecode.com/svn/tags/ctemplate-0.94/ChangeLog +ChangeLog]. + +=== 20 August 2008 === + +ctemplate 0.91 introduces the beginning of some API changes, as I look +to clean up the API in preparation for ctemplate 1.0. After 1.0, the +API will remain backwards compatible, but until that time, the API may +change. Please take a look at the +[http://google-ctemplate.googlecode.com/svn/trunk/ChangeLog ChangeLog] +to see if any of these changes affect you. + +One change is the introduction of a new `PerExpandData` class, which +holds some state that was formerly in the `TemplateDictionary` class. +I'm still not sure if this class is a good idea, if it should be +separate from `TemplateDictionary` or a member, or what functionality +should move there (for instance, should `SetTemplateGlobal` move +there, since template-global variables are really, in some sense, +per-expand variables?) If you have any feedback, ideally based on +your own experience using the current API, feel free to post it at +`google-ctemplate@googlegroups.com`. + +ctemplate also has several new features, including the addition of +"separator" sections, and the ability to change the markup character +(from `{{`). See the +[http://google-ctemplate.googlecode.com/svn/trunk/ChangeLog ChangeLog] +for a complete list, and the +[http://google-ctemplate.googlecode.com/svn/trunk/doc/howto.html howto +documentation] for more details on these new features. diff --git a/README.windows b/README_windows.txt similarity index 85% rename from README.windows rename to README_windows.txt index 58f2950..c40acae 100644 --- a/README.windows +++ b/README_windows.txt @@ -1,38 +1,43 @@ -This project has been ported to Windows. A working solution file -exists in this directory: - google-ctemplate.sln - -You can load this solution file into either VC++ 7.1 (Visual Studio -2003) or VC++ 8.0 (Visual Studio 2005) -- in the latter case, it will -automatically convert the files to the latest format for you. - -When you build the solution, it will create libctemplate.dll, the main -library for this project, plus a number of unittests, which you can -run by hand (or, more easily, under the Visual Studio debugger) to -make sure everything is working properly on your system. The binaries -will end up in a directory called "debug" or "release" in the -top-level directory (next to the .sln file). - -If you wish to link to ctemplate statically instead of using the .dll, -you can; see the example project template_unittest_static. For this -to work, you'll need to add "/D CTEMPLATE_DLL_DECL=" to the compile -line of every ctemplate .cc file. - -Note that these systems are set to build in Debug mode by default. -You may want to change them to Release mode. - -Currently, Template::StringToTemplate returns a Template object that -you, the caller, must free. We've heard reports that Windows can have -trouble allocating memory in a .dll that is meant to be freed in the -application. Thus, we suggest you not use StringToTemplate from -Windows. Instead, you can use Template::StringToTemplateCache() -followed by Template::GetTemplate(). - -I have little experience with Windows programming, so there may be -better ways to set this up than I've done! If you run across any -problems, please post to the google-ctemplate Google Group, or report -them on the google-ctemplate Google Code site: - http://groups.google.com/group/google-ctemplate - http://code.google.com/p/google-ctemplate/issues/list - --- craig +This project has been ported to Windows. A working solution file +exists in this directory: + google-ctemplate.sln + +You can load this solution file into either VC++ 7.1 (Visual Studio +2003) or VC++ 8.0 (Visual Studio 2005) -- in the latter case, it will +automatically convert the files to the latest format for you. + +When you build the solution, it will create libctemplate.dll, the main +library for this project, plus a number of unittests, which you can +run by hand (or, more easily, under the Visual Studio debugger) to +make sure everything is working properly on your system. The binaries +will end up in a directory called "debug" or "release" in the +top-level directory (next to the .sln file). + +I don't know very much about how to install DLLs on Windows, so you'll +have to figure out that part for yourself. If you choose to just +re-use the existing .sln, make sure you set the IncludeDir's +appropriately! Look at the properties for libctemplate.dll. + +If you wish to link to ctemplate statically instead of using the .dll, +you can; see the example project template_unittest_static. For this +to work, you'll need to add "/D CTEMPLATE_DLL_DECL=" to the compile +line of every ctemplate .cc file. + +Note that these systems are set to build in Debug mode by default. +You may want to change them to Release mode. + +Currently, Template::StringToTemplate returns a Template object that +you, the caller, must free. We've heard reports that Windows can have +trouble allocating memory in a .dll that is meant to be freed in the +application. Thus, we suggest you not use StringToTemplate from +Windows. Instead, you can use Template::StringToTemplateCache() +followed by Template::GetTemplate(). + +I have little experience with Windows programming, so there may be +better ways to set this up than I've done! If you run across any +problems, please post to the google-ctemplate Google Group, or report +them on the google-ctemplate Google Code site: + http://groups.google.com/group/google-ctemplate + http://code.google.com/p/google-ctemplate/issues/list + +-- craig diff --git a/doc/auto_escape.html b/doc/auto_escape.html index 299bc59..ee9f74f 100644 --- a/doc/auto_escape.html +++ b/doc/auto_escape.html @@ -94,12 +94,12 @@ the appropriate escaping modifiers after your own.
that use but allows you to indicate a different choice as shown below: -TemplateContext | Primary Modifier | Accepted alternatives | |
---|---|---|---|
TC_HTML |
+ TC_HTML |
:html_escape |
|
:cleanse_css |
|
@@ -125,7 +127,7 @@ the appropriate escaping modifiers after your own.
|
+
:javascript_escape |
|
+
Context | HTML Quoted? | Examples | Action Performed | |
---|---|---|---|---|
Regular HTML Body and HTML comments | Any | <p>Hello {{USER}}</p> |
@@ -173,95 +175,95 @@ the failure.
||
In URL attribute: Starts at pos 0 | Yes | -<img src="{{URL}}">; |
+ <a href="{{URL}}">; |
Escape URL using
:url_escape_with_arg=html |
In URL attribute: Other | Yes | <a href="/foo?q={{QUERY}}"> |
Escape QUERY using
:html_escape |
|
In URL attribute: Starting at pos 0 | No | <form action={{URL}}> |
Fail template initialization | |
In URL attribute: Other | No | <a href=/foo?q={{QUERY}}>My Link</a> |
Escape QUERY using
:url_query_escape |
|
In STYLE attribute | Yes | <div style="color:{{COLOR}};"> |
Escape COLOR using
:cleanse_css |
|
In STYLE attribute | No | <div style=color:{{COLOR}};> |
Fail template initialization | |
In Javascript attribute: String literal | Yes | <a href="url" onclick="doFoo('{{ARG}}');"> |
Escape ARG using
:javascript_escape |
|
In Javascript attribute: Non-string literal | Yes | <a href="url" onclick="doFoo({{ARG}});"> |
Escape ARG using
:javascript_escape_with_arg=number |
|
In Javascript attribute: Any | No | <a href="url" onclick=doFoo('{{ARG}}');> |
Fail template initialization. | |
In all other attributes | Yes | <b class="{{CLASS}}"> |
Escape CLASS using
:html_escape |
|
In all other attributes | No | <table border={{BORDER}}> |
Escape BORDER using
:html_escape_with_arg=attribute |
|
In Javascript code: In a string literal | Any | <script>var a = '{{VALUE}}';</script> |
Escape VALUE using
:javascript_escape |
|
In Javascript code: Non-string literal | Any | <script>var a = {{VALUE}};</script> |
Escape VALUE using
:javascript_escape_with_arg=number |
|
In a <style> tag | Any | <style>font-size={{FONTSIZE}};</style> |
Escape FONTSIZE using
@@ -270,7 +272,7 @@ the failure.
|
TC_JS
) templates are well supported.
Other template contexts have only basic support.
For these contexts, variables are escaped as follows:
- TemplateContext | Escaping Applied | |
---|---|---|
TC_JSON | :javascript_escape |
long name | short name | description |
---|---|---|
:cleanse_css | :c |
+ Removes characters not safe for a CSS value. Safe characters + are alphanumeric, space, underscore, period, coma, exclamation + mark, pound, percent, and dash. | +
:html_escape | :h |
html-escapes the variable before output
(eg & -> & ) |
:html_escape_with_arg | :H |
+ special purpose html escaping. See + :H Arguments + below for details. | +
:img_src_url_escape_with_arg | :I |
+ special purpose image url escaping. See + :I and :U Arguments + below for details. | +
:javascript_escape | :j |
+ javascript-escapes the variable before output (eg
+ " -> \x27 and
+ & -> \x26 ) |
+
:javascript_escape_with_arg | :J
+ |
+ special purpose javascript escaping. See + :J Arguments + below for details. | +
:json_escape | :o |
+ json-escapes a variable before output as a string in json;
+ HTML characters are escaped using Unicode escape sequences
+ (e.g & -> \u0026 ) to comply with
+ RFC 4627.
+ |
+
:none | + | leaves the variable as is (used to disable auto-escaping) | +
:pre_escape | :p |
pre-escapes the variable before output (same as html_escape but whitespace is preserved; useful for <pre>...</pre>) |
:url_escape_with_arg | :U |
+ special purpose url escaping. See + :I and :U Arguments + below for details. | +
:url_query_escape | :u |
performs URL escaping on the variable before output. space is turned into +, and everything other than [0-9a-zA-Z.,_:*/~!()-], is @@ -1018,39 +1067,6 @@ They are all defined in template_modifiers.cc: |
:javascript_escape | :j |
- javascript-escapes the variable before output (eg
- " -> \x27 and
- & -> \x26 ) |
-
:javascript_escape_with_arg | :J
- |
- special purpose javascript escaping. See below for details. | -
:cleanse_css | :c |
- Removes characters not safe for a CSS value. Safe characters - are alphanumeric, space, underscore, period, coma, exclamation - mark, pound, percent, and dash. | -
:json_escape | :o |
- json-escapes a variable before output as a string in json;
- HTML characters are escaped using Unicode escape sequences
- (e.g & -> \u0026 ) to comply with
- RFC 4627.
- |
-
:html_escape_with_arg | :H |
- special purpose html escaping. See below for details. | -
:url_escape_with_arg | :U |
- special purpose url escaping. See below for details. | -
:xml_escape | xml-escapes the variable before output
(the five characters <>&"' become
@@ -1059,19 +1075,16 @@ They are all defined in template_modifiers.cc:
for escaping content within CDATA blocks. |
|
:none | - | leaves the variable as is (used to disable auto-escaping) | -
The *_with_arg
modifiers require an argument to
-specify the type of escaping to use.
+specify the type of escaping to use. The following sections list
+the supported arguments for each of these modifiers.
+
Here are the values that are supported by
the html_escape_with_arg
modifier:
value | description |
---|---|
=snippet |
@@ -1097,16 +1110,33 @@ the
Here are the values that are supported by
-the url_escape_with_arg
modifier:
value | description | |
---|---|---|
=html |
Ensures that a variable contains a safe URL. Safe means that
it is either a http or https URL, or else it has no protocol
- specified. If the URL is safe it is html-escaped, otherwise
- it is replaced with # . |
+ specified.
+ |
=javascript |
@@ -1123,14 +1153,16 @@ the ||
=query |
- Same as url_query_escape . |
+ (Supported for :U only) Same as
+ url_query_escape . |
Here are the values that are supported by
the javascript_escape_with_arg
modifier:
value | description |
---|---|
=number |
@@ -1149,12 +1181,6 @@ the
NOTE: At the moment, there are no filters for -handling XML attributes and text nodes. For HTML snippets, use the -html filter; in other situations, it may be appropriate to use CDATA -blocks.
- -In addition to the built-in modifiers, you can write your own @@ -1480,7 +1506,7 @@ workflow: the common template use-case would be:
Template* tpl = Template::GetTemplate(filename, strip_mode); TemplateDictionary dict(name); - tpl->Expand(&dict, &outstring); + tpl->Expand(&dict, &outstring);
In current use, this model is deprecated in favor of the single
diff --git a/packages/deb/control b/packages/deb/control
index 0ddf5dc..5c2c8e1 100644
--- a/packages/deb/control
+++ b/packages/deb/control
@@ -1,7 +1,7 @@
Source: ctemplate
Section: libdevel
Priority: optional
-Maintainer: Google Inc. tags, it is not safe to set
+// the src attribute to "#". This is because this causes some browsers
+// to reload the page, which can cause a DoS.
class @ac_windows_dllexport@ ValidateUrl : public TemplateModifier {
public:
- explicit ValidateUrl(const TemplateModifier& chained_modifier)
- : chained_modifier_(chained_modifier) { }
+ explicit ValidateUrl(const TemplateModifier& chained_modifier,
+ const char* unsafe_url_replacement)
+ : chained_modifier_(chained_modifier),
+ unsafe_url_replacement_(unsafe_url_replacement),
+ unsafe_url_replacement_length_(strlen(unsafe_url_replacement)) { }
MODIFY_SIGNATURE_;
+ static const char* const kUnsafeUrlReplacement;
+ static const char* const kUnsafeImgSrcUrlReplacement;
private:
const TemplateModifier& chained_modifier_;
+ const char* unsafe_url_replacement_;
+ int unsafe_url_replacement_length_;
};
extern @ac_windows_dllexport@ ValidateUrl validate_url_and_html_escape;
extern @ac_windows_dllexport@ ValidateUrl validate_url_and_javascript_escape;
extern @ac_windows_dllexport@ ValidateUrl validate_url_and_css_escape;
+extern @ac_windows_dllexport@ ValidateUrl validate_img_src_url_and_html_escape;
+extern @ac_windows_dllexport@ ValidateUrl validate_img_src_url_and_javascript_escape;
+extern @ac_windows_dllexport@ ValidateUrl validate_img_src_url_and_css_escape;
// Escapes < > & " ' to < > & " ' (same as in HtmlEscape).
// If you use it within a CDATA section, you may be escaping more characters
diff --git a/src/make_tpl_varnames_h.cc b/src/make_tpl_varnames_h.cc
index 1321db2..5e9a78a 100644
--- a/src/make_tpl_varnames_h.cc
+++ b/src/make_tpl_varnames_h.cc
@@ -124,12 +124,12 @@ static void Version(FILE* outfile) {
// Removes all non alphanumeric characters from a string to form a
// valid C identifier to use as a double-inclusion guard.
-static void ConvertToIdentifier(string& s) {
- for (string::size_type i = 0; i < s.size(); i++) {
- if (!isalnum(s[i]))
- s[i] = '_';
+static void ConvertToIdentifier(string* s) {
+ for (string::size_type i = 0; i < s->size(); i++) {
+ if (!isalnum((*s)[i]))
+ (*s)[i] = '_';
else
- s[i] = toupper(s[i]);
+ (*s)[i] = toupper((*s)[i]);
}
}
@@ -256,7 +256,7 @@ int main(int argc, char **argv) {
"//\n");
string guard(string("TPL_") + header_file);
- ConvertToIdentifier(guard);
+ ConvertToIdentifier(&guard);
guard.append("_H_");
contents.append(string("#ifndef ") + guard + "\n");
diff --git a/src/per_expand_data.cc b/src/per_expand_data.cc
index 52b4f72..dbbe041 100644
--- a/src/per_expand_data.cc
+++ b/src/per_expand_data.cc
@@ -49,6 +49,10 @@ bool PerExpandData::DataEq::operator()(const char* s1, const char* s2) const {
}
#endif
+PerExpandData::~PerExpandData() {
+ delete map_;
+}
+
TemplateAnnotator* PerExpandData::annotator() const {
if (annotator_ != NULL) {
return annotator_;
@@ -59,4 +63,19 @@ TemplateAnnotator* PerExpandData::annotator() const {
return &g_default_annotator;
}
+void PerExpandData::InsertForModifiers(const char* key, const void* value) {
+ if (!map_)
+ map_ = new DataMap;
+ (*map_)[key] = value;
+}
+
+ // Retrieve data specific to this Expand call. Returns NULL if key
+ // is not found. This should only be used by template modifiers.
+const void* PerExpandData::LookupForModifiers(const char* key) const {
+ if (!map_)
+ return NULL;
+ const DataMap::const_iterator it = map_->find(key);
+ return it == map_->end() ? NULL : it->second;
+}
+
} // namespace ctemplate
diff --git a/src/template.cc b/src/template.cc
index 5b3b1fc..07a3fb6 100644
--- a/src/template.cc
+++ b/src/template.cc
@@ -35,8 +35,8 @@
#include "base/mutex.h" // This must go first so we get _XOPEN_SOURCE
#include
tags, it is not safe to set
+// the src attribute to "#". This is because this causes some browsers
+// to reload the page, which can cause a DoS.
class CTEMPLATE_DLL_DECL ValidateUrl : public TemplateModifier {
public:
- explicit ValidateUrl(const TemplateModifier& chained_modifier)
- : chained_modifier_(chained_modifier) { }
+ explicit ValidateUrl(const TemplateModifier& chained_modifier,
+ const char* unsafe_url_replacement)
+ : chained_modifier_(chained_modifier),
+ unsafe_url_replacement_(unsafe_url_replacement),
+ unsafe_url_replacement_length_(strlen(unsafe_url_replacement)) { }
MODIFY_SIGNATURE_;
+ static const char* const kUnsafeUrlReplacement;
+ static const char* const kUnsafeImgSrcUrlReplacement;
private:
const TemplateModifier& chained_modifier_;
+ const char* unsafe_url_replacement_;
+ int unsafe_url_replacement_length_;
};
extern CTEMPLATE_DLL_DECL ValidateUrl validate_url_and_html_escape;
extern CTEMPLATE_DLL_DECL ValidateUrl validate_url_and_javascript_escape;
extern CTEMPLATE_DLL_DECL ValidateUrl validate_url_and_css_escape;
+extern CTEMPLATE_DLL_DECL ValidateUrl validate_img_src_url_and_html_escape;
+extern CTEMPLATE_DLL_DECL ValidateUrl validate_img_src_url_and_javascript_escape;
+extern CTEMPLATE_DLL_DECL ValidateUrl validate_img_src_url_and_css_escape;
// Escapes < > & " ' to < > & " ' (same as in HtmlEscape).
// If you use it within a CDATA section, you may be escaping more characters
diff --git a/src/windows/preprocess.sh b/src/windows/preprocess.sh
index af6bf34..c6d691f 100755
--- a/src/windows/preprocess.sh
+++ b/src/windows/preprocess.sh
@@ -58,6 +58,21 @@ DLLDEF_DEFINES="\
# define $DLLDEF_MACRO_NAME __declspec(dllimport)\n\
#endif"
+# template_cache.h gets a special DEFINE to work around the
+# difficulties in dll-exporting stl containers. Ugh.
+TEMPLATE_CACHE_DLLDEF_DEFINES="\
+// NOTE: if you are statically linking the template library into your binary\n\
+// (rather than using the template .dll), set '/D $DLLDEF_MACRO_NAME='\n\
+// as a compiler flag in your project file to turn off the dllimports.\n\
+#ifndef $DLLDEF_MACRO_NAME\n\
+# define $DLLDEF_MACRO_NAME __declspec(dllimport)\n\
+extern template class __declspec(dllimport) std::allocator