Fix for #549.
authorcli
Fri Aug 21 17:33:15 2009 +0200 (2009-08-21)
changeset 187e527fdf0fa8
parent 17 4ae6ada7ea23
child 19 91dc9acb03ed
Fix for #549.
org/sonews/daemon/command/PostCommand.java
org/sonews/storage/ArticleHead.java
org/sonews/util/io/ArticleWriter.java
     1.1 --- a/org/sonews/daemon/command/PostCommand.java	Thu Aug 20 22:18:45 2009 +0200
     1.2 +++ b/org/sonews/daemon/command/PostCommand.java	Fri Aug 21 17:33:15 2009 +0200
     1.3 @@ -178,48 +178,6 @@
     1.4              state = PostState.Finished;
     1.5              break;
     1.6            }
     1.7 -          
     1.8 -          // Check if this message is a MIME-multipart message and needs a
     1.9 -          // charset change
    1.10 -          /*try
    1.11 -          {
    1.12 -            line = line.toLowerCase(Locale.ENGLISH);
    1.13 -            if(line.startsWith(Headers.CONTENT_TYPE))
    1.14 -            {
    1.15 -              int idxStart = line.indexOf("charset=") + "charset=".length();
    1.16 -              int idxEnd   = line.indexOf(";", idxStart);
    1.17 -              if(idxEnd < 0)
    1.18 -              {
    1.19 -                idxEnd = line.length();
    1.20 -              }
    1.21 -
    1.22 -              if(idxStart > 0)
    1.23 -              {
    1.24 -                String charsetName = line.substring(idxStart, idxEnd);
    1.25 -                if(charsetName.length() > 0 && charsetName.charAt(0) == '"')
    1.26 -                {
    1.27 -                  charsetName = charsetName.substring(1, charsetName.length() - 1);
    1.28 -                }
    1.29 -
    1.30 -                try
    1.31 -                {
    1.32 -                  conn.setCurrentCharset(Charset.forName(charsetName));
    1.33 -                }
    1.34 -                catch(IllegalCharsetNameException ex)
    1.35 -                {
    1.36 -                  Log.msg("PostCommand: " + ex, false);
    1.37 -                }
    1.38 -                catch(UnsupportedCharsetException ex)
    1.39 -                {
    1.40 -                  Log.msg("PostCommand: " + ex, false);
    1.41 -                }
    1.42 -              } // if(idxStart > 0)
    1.43 -            }
    1.44 -          }
    1.45 -          catch(Exception ex)
    1.46 -          {
    1.47 -            ex.printStackTrace();
    1.48 -          }*/
    1.49          }
    1.50          break;
    1.51        }
    1.52 @@ -292,6 +250,15 @@
    1.53      }
    1.54      else // Post the article regularily
    1.55      {
    1.56 +      // Circle check; note that Path can already contain the hostname here
    1.57 +      String host = Config.inst().get(Config.HOSTNAME, "localhost");
    1.58 +      if(article.getHeader(Headers.PATH)[0].contains(host + "!"))
    1.59 +      {
    1.60 +        Log.get().info(article.getMessageID() + " skipped for host " + host);
    1.61 +        conn.println("441 I know this article already");
    1.62 +        return;
    1.63 +      }
    1.64 +
    1.65        // Try to create the article in the database or post it to
    1.66        // appropriate mailing list
    1.67        try
     2.1 --- a/org/sonews/storage/ArticleHead.java	Thu Aug 20 22:18:45 2009 +0200
     2.2 +++ b/org/sonews/storage/ArticleHead.java	Fri Aug 21 17:33:15 2009 +0200
     2.3 @@ -136,7 +136,7 @@
     2.4      validateHeaders();
     2.5    }
     2.6  
     2.7 -    /**
     2.8 +  /**
     2.9     * Checks some headers for their validity and generates an
    2.10     * appropriate Path-header for this host if not yet existing.
    2.11     * This method is called by some Article constructors and the
     3.1 --- a/org/sonews/util/io/ArticleWriter.java	Thu Aug 20 22:18:45 2009 +0200
     3.2 +++ b/org/sonews/util/io/ArticleWriter.java	Fri Aug 21 17:33:15 2009 +0200
     3.3 @@ -65,7 +65,7 @@
     3.4      this.out.write("\r\n.\r\n".getBytes());
     3.5      this.out.flush();
     3.6      String line = inr.readLine();
     3.7 -    if(line == null || !line.startsWith("240 "))
     3.8 +    if(line == null || !line.startsWith("240 ") || !line.startsWith("441 "))
     3.9      {
    3.10        throw new IOException(line);
    3.11      }