Author: toad
Date: 2007-05-10 00:58:14 +0000 (Thu, 10 May 2007)
New Revision: 13190
Modified:
trunk/freenet/src/freenet/clients/http/filter/CSSReadFilter.java
trunk/freenet/src/freenet/clients/http/filter/ContentFilter.java
trunk/freenet/src/freenet/l10n/freenet.l10n.en.properties
Log:
Some l10n keys for the content filter code.
There will be more.
Once that's done, we're pretty much done with l10n keys.
Modified: trunk/freenet/src/freenet/clients/http/filter/CSSReadFilter.java
===================================================================
--- trunk/freenet/src/freenet/clients/http/filter/CSSReadFilter.java
2007-05-10 00:46:16 UTC (rev 13189)
+++ trunk/freenet/src/freenet/clients/http/filter/CSSReadFilter.java
2007-05-10 00:58:14 UTC (rev 13190)
@@ -15,6 +15,7 @@
import java.io.Writer;
import java.util.HashMap;
+import freenet.l10n.L10n;
import freenet.support.HTMLEncoder;
import freenet.support.HTMLNode;
import freenet.support.Logger;
@@ -48,11 +49,12 @@
os.close();
strm.close();
HTMLNode explanation = new HTMLNode("p");
- explanation.addChild("b", "Unknown character set!");
- explanation.addChild("#", " The page you are about to
display has an unknown character set. This means that we are not able to filter
the page, and it may compromize your anonymity.");
- throw new DataFilterException("Warning: Unknown
character set ("+charset+ ')', "Warning: Unknown character set
("+HTMLEncoder.encode(charset)+ ')',
- "<p><b>Unknown character set</b> The
page you are about to display has an unknown character set. "+
- "This means that we are not able to
filter the page, and it may compromize your anonymity.</p>", explanation);
+ String explTitle = l10nDF("unknownCharsetTitle");
+ String expl = l10nDF("unknownCharset");
+ explanation.addChild("b", explTitle);
+ explanation.addChild("#", " " + expl);
+ String warning = l10nDF("warningUnknownCharsetTitle",
"charset", charset);
+ throw new DataFilterException(warning, warning,
explTitle + " " + expl, explanation);
}
CSSParser parser = new CSSParser(r, w, false, cb);
parser.parse();
@@ -61,6 +63,16 @@
return temp;
}
+ private static String l10nDF(String key) {
+ // All the strings here are generic
+ return L10n.getString("ContentDataFilter."+key);
+ }
+
+ private static String l10nDF(String key, String pattern, String value) {
+ // All the strings here are generic
+ return L10n.getString("ContentDataFilter."+key, pattern, value);
+ }
+
public Bucket writeFilter(Bucket data, BucketFactory bf, String charset,
HashMap otherParams, FilterCallback cb) throws
DataFilterException,
IOException {
Modified: trunk/freenet/src/freenet/clients/http/filter/ContentFilter.java
===================================================================
--- trunk/freenet/src/freenet/clients/http/filter/ContentFilter.java
2007-05-10 00:46:16 UTC (rev 13189)
+++ trunk/freenet/src/freenet/clients/http/filter/ContentFilter.java
2007-05-10 00:58:14 UTC (rev 13190)
@@ -11,6 +11,7 @@
import java.util.HashMap;
import java.util.Hashtable;
+import freenet.l10n.L10n;
import freenet.support.Logger;
import freenet.support.api.Bucket;
import freenet.support.api.BucketFactory;
@@ -32,62 +33,65 @@
// Plain text
register(new MIMEType("text/plain", "txt", new String[0], new
String[] { "text", "pot" },
- true, true, null, null, false, false, false,
false, false, false,
- "Plain text - not dangerous unless your browser
is stupid (e.g. Internet Explorer)",
- "Plain text - not dangerous unless you include
compromizing information",
+ true, true, null, null, false, false, false,
false, false, false,
+ l10n("textPlainReadAdvice"),
+ l10n("textPlainWriteAdvice"),
true, "US-ASCII", null));
// GIF - has a filter
register(new MIMEType("image/gif", "gif", new String[0], new
String[0],
true, false, new GIFFilter(), null, false,
false, false, false, false, false,
- "GIF image - probably not dangerous",
- "GIF image - probably not dangerous but you
should wipe any comments",
+ l10n("imageGifReadAdvice"),
+ l10n("imageGifWriteAdvice"),
false, null, null));
// JPEG - has a filter
register(new MIMEType("image/jpeg", "jpeg", new String[0], new
String[] { "jpg" },
true, false, new JPEGFilter(true, true), null,
false, false, false, false, false, false,
- "JPEG image - probably not dangerous",
- "JPEG image - probably not dangerous but can
contain EXIF data", false, null, null));
+ l10n("imageJpegReadAdvice"),
+ l10n("imageJpegWriteAdvice"), false, null,
null));
// PNG - has a filter
register(new MIMEType("image/png", "png", new String[0], new
String[0],
true, false, new PNGFilter(), null, false,
false, false, false, true, false,
- "PNG image - probably not dangerous",
- "PNG image - probably not dangerous but you
should wipe any comments or text blocks",
- false, null, null));
+ l10n("imagePngReadAdvice"),
+ l10n("imagePngWriteAdvice"), false, null,
null));
// ICO - probably safe - FIXME check this out, write filters
register(new MIMEType("image/x-icon", "ico", new String[] {
"image/vnd.microsoft.icon", "image/ico", "application/ico"},
new String[0], true, false, null, null, false,
false, false, false, false, false,
- "Icon file - probably not dangerous",
- "Icon file - probably not dangerous (but can
contain other data due to offset?)",
- false, null, null));
+ l10n("imageIcoReadAdvice"),
+ l10n("imageIcoWriteAdvice"), false, null,
null));
// PDF - very dangerous - FIXME ideally we would have a filter,
this is such a common format...
register(new MIMEType("application/pdf", "pdf", new String[] {
"application/x-pdf" }, new String[0],
false, false, null, null, true, true, true,
false, true, true,
- "Adobe(R) PDF document - VERY DANGEROUS!",
- "Adobe(R) PDF document - VERY DANGEROUS!",
+ l10n("applicationPdfReadAdvice"),
+ l10n("applicationPdfWriteAdvice"),
false, null, null));
// HTML - dangerous if not filtered
register(new MIMEType("text/html", "html", new String[] {
"text/xhtml", "text/xml+xhtml", "application/xhtml+xml" }, new String[] { "htm"
},
false, false /* maybe? */, new HTMLFilter(),
null /* FIXME */,
- true, true, true, true, true, true, "HTML - not
dangerous if filtered",
- "HTML - may contain dangerous metadata etc;
suggest you check it by hand",
+ true, true, true, true, true, true,
+ l10n("textHtmlReadAdvice"),
+ l10n("textHtmlWriteAdvice"),
true, "iso-8859-1", new HTMLFilter()));
// CSS - danagerous if not filtered, not sure about the filter
register(new MIMEType("text/css", "css", new String[0], new
String[0],
false, false /* unknown */, new
CSSReadFilter(), null,
true, true, true, true, true, false,
- "CSS (cascading style sheet, usually used with
HTML) - probably not dangerous if filtered, but the filter is not a whitelist
filter so take care",
- "CSS (cascading style sheet, usually used with
HTML) - this can probably contain metadata, check it by hand",
+ l10n("textCssReadAdvice"),
+ l10n("textCssWriteAdvice"),
true, "utf-8", new CSSReadFilter()));
}
+ private static String l10n(String key) {
+ return L10n.getString("ContentFilter."+key);
+ }
+
public static void register(MIMEType mimeType) {
synchronized(mimeTypesByName) {
mimeTypesByName.put(mimeType.primaryMimeType, mimeType);
Modified: trunk/freenet/src/freenet/l10n/freenet.l10n.en.properties
===================================================================
--- trunk/freenet/src/freenet/l10n/freenet.l10n.en.properties 2007-05-10
00:46:16 UTC (rev 13189)
+++ trunk/freenet/src/freenet/l10n/freenet.l10n.en.properties 2007-05-10
00:58:14 UTC (rev 13190)
@@ -840,4 +840,24 @@
ShortOption.parseError=Cannot parse value as a string array: ${error}
ConfigurablePersister.existsCannotReadWrite=File exists and cannot read/write
it
ConfigurablePersister.doesNotExistCannotCreate=File does not exist and cannot
be created
+ContentFilter.textPlainReadAdvice=Plain text - not dangerous unless your
browser is stupid (e.g. Internet Explorer)
+ContentFilter.textPlainWriteAdvice=Plain text - not dangerous unless you
include compromizing information
+ContentFilter.imageGifReadAdvice=GIF image - probably not dangerous
+ContentFilter.imageGifWriteAdvice=GIF image - probably not dangerous but you
should wipe any comments
+ContentFilter.imageJpegReadAdvice=JPEG image - probably not dangerous
+ContentFilter.imageJpegWriteAdvice=JPEG image - probably not dangerous but can
contain EXIF data
+ContentFilter.imagePngReadAdvice=PNG image - probably not dangerous
+ContentFilter.imagePngWriteAdvice=PNG image - probably not dangerous but you
should wipe any comments or text blocks
+ContentFilter.imageIcoReadAdvice=Icon file - probably not dangerous
+ContentFilter.imageIcoWriteAdvice=Icon file - probably not dangerous (but can
contain other data due to offset?)
+ContentFilter.applicationPdfReadAdvice=Adobe(R) PDF document - VERY DANGEROUS!
+ContentFilter.applicationPdfWriteAdvice=Adobe(R) PDF document - VERY DANGEROUS!
+ContentFilter.textHtmlReadAdvice=HTML - not dangerous if filtered
+ContentFilter.textHtmlWriteAdvice=HTML - may contain dangerous metadata etc;
suggest you check it by hand
+ContentFilter.textCssReadAdvice=CSS (cascading style sheet, usually used with
HTML) - probably not dangerous if filtered, but the filter is not a whitelist
filter so take care
+ContentFilter.textCssWriteAdvice=CSS (cascading style sheet, usually used with
HTML) - this can probably contain metadata, check it by hand
+ContentDataFilter.unknownCharsetTitle=Unknown character set!
+ContentDataFilter.unknownCharset=The page you are about to display has an
unknown character set. This means that we are not able to filter the page, and
it may compromize your anonymity.
+ContentDataFilter.warningUnknownCharsetTitle=Warning: Unknown character set
(${charset})
+ContentDataFilter.warningUnknownCharset=
End
\ No newline at end of file