fixed bug in package parser (wrong length of .PKGINFO file was used)

This commit is contained in:
2016-04-16 10:11:54 +02:00
parent fa51e60bc6
commit 3385cafc32
4 changed files with 12 additions and 121 deletions

View File

@@ -110,7 +110,7 @@ public class JPacRepoApp extends WApplication
previousItem.clicked().addListener(this, () ->
{
int newIndex = pageMenu.getCurrentIndex() - 1;
if(newIndex>=0)
if (newIndex >= 0)
{
pageMenu.select(newIndex);
pageMenu.itemAt(newIndex).clicked().trigger(new WMouseEvent());
@@ -120,7 +120,7 @@ public class JPacRepoApp extends WApplication
nextItem.clicked().addListener(this, () ->
{
int newIndex = pageMenu.getCurrentIndex() + 1;
if(newIndex<pageMenu.getCount())
if (newIndex < pageMenu.getCount())
{
pageMenu.select(newIndex);
pageMenu.itemAt(newIndex).clicked().trigger(new WMouseEvent());
@@ -156,7 +156,7 @@ public class JPacRepoApp extends WApplication
packageNameEdit.blurred().addListener(this, () ->
{
if(!packageNameEdit.getDisplayText().equals(lastName))
if (!packageNameEdit.getDisplayText().equals(lastName))
{
lastName = packageNameEdit.getDisplayText();
Map<String, String> predicateMap = new HashMap<>();
@@ -207,7 +207,7 @@ public class JPacRepoApp extends WApplication
.generateReplacerJS(contactOptions), parent);
popup.forEdit(linkedFormWidget, EnumSet.of(WSuggestionPopup.PopupTrigger.Editing, WSuggestionPopup.PopupTrigger.DropDownIcon));
List<WString> wstrings = new ArrayList<>();
for(String suggestion :suggestions)
for (String suggestion : suggestions)
{
wstrings.add(new WString(suggestion));
// popup.addSuggestion(suggestion);

View File

@@ -36,30 +36,30 @@ public class Parser
if(ae.getName().equals(".PKGINFO"))
{
Map<String, List<String>> propMap = new HashMap<>();
byte[] buffer = new byte[tais.getRecordSize()];
byte[] buffer = new byte[(int)tais.getCurrentEntry().getSize()];
tais.read(buffer);
String info = new String(buffer, Charset.forName("UTF8"));
for(String line : info.split("\n"))
{
if(line.startsWith("#"))
if(line.startsWith("#") || line.trim().length() == 0)
{
continue;
}
else
{
String[] pair = line.split(" = ");
if(pair.length > 2)
int equals = line.indexOf("=");
if(equals < 0)
{
throw new RuntimeException("Error parsing .PKGINFO file");
}
else if(pair.length == 2)
else
{
String key = pair[0].trim();
String key = line.substring(0, equals).trim();
if(propMap.get(key) == null)
{
propMap.put(key, new ArrayList<>());
}
propMap.get(key).add(pair[1].trim());
propMap.get(key).add(line.substring(equals+1, line.length()).trim());
}
}
}