Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce errors while processing plugins #268

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/main/java/org/jivesoftware/site/DownloadStats.java
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,10 @@ public void run() {
*/
public static void addListingToDatabase( String ipAddress, String product, String os, int type, ServletContext context )
{
// Correct for X-Forwarded-For header value sometimes containing a list of IPs. Use the last one.
if (ipAddress != null && ipAddress.contains(",")) {
ipAddress = ipAddress.substring(ipAddress.indexOf(",")+1).trim();
}
final DbConnectionManager connectionManager = DbConnectionManager.getInstance();
Connection con = null;
PreparedStatement pstmt = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,10 @@ public static String getMetadataFromPlugin( ZipFile archive, String propertyPath
{
try ( final InputStream in = getUncompressedEntryFromArchive( archive, "plugin.xml" ) )
{
if (in == null) {
Log.info("Unable to find 'plugin.xml' in '{}", archive);
return null;
}
final SAXReader saxReader = new SAXReader();
final Document doc = saxReader.read(in);
final Element element = (Element)doc.selectSingleNode( propertyPath );
Expand Down
6 changes: 6 additions & 0 deletions src/main/java/org/jivesoftware/site/PluginManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import static org.jivesoftware.site.PluginDownloadServlet.getUncompressedEntryFromArchive;

public class PluginManager
{
private static final Logger Log = LoggerFactory.getLogger( PluginManager.class );
Expand Down Expand Up @@ -382,6 +384,10 @@ public Metadata( Path mavenFile ) throws IOException, DocumentException
this.mavenFile = mavenFile;
try ( final JarFile archive = new JarFile( mavenFile.toFile() ) )
{
if (getUncompressedEntryFromArchive(archive, "plugin.xml") == null) {
throw new IOException("Unable to find 'plugin.xml' in: " + mavenFile);
}

this.hasReadme = PluginDownloadServlet.archiveContainsEntry( archive, "readme.html");
this.hasChangelog = PluginDownloadServlet.archiveContainsEntry( archive, "changelog.html");

Expand Down
Loading