clean up whitespace in repo descriptions

This cleans up the whitespace in the description item, since the
XML parsing will include the linefeeds and indenting in the description.
This commit is contained in:
Hans-Christoph Steiner 2018-10-16 17:31:33 +02:00
parent 1788546267
commit 6dd4523d3c
2 changed files with 10 additions and 1 deletions

View File

@ -291,6 +291,9 @@ public class DBHelper extends SQLiteOpenHelper {
* <p>
* Additional Repos ({@code additional_repos.xml}) come from the ROM,
* while Default Repos ({@code default_repos.xml} is built into the APK.
* <p>
* This also cleans up the whitespace in the description item, since the
* XML parsing will include the linefeeds and indenting in the description.
*/
public static List<String> loadInitialRepos(Context context) throws IllegalArgumentException {
String packageName = context.getPackageName();
@ -303,6 +306,12 @@ public class DBHelper extends SQLiteOpenHelper {
initialRepos.size() + " % REPO_XML_ARG_COUNT(" + REPO_XML_ITEM_COUNT + ") != 0");
}
final int DESCRIPTION_INDEX = 2;
for (int i = DESCRIPTION_INDEX; i < initialRepos.size(); i += REPO_XML_ITEM_COUNT) {
String description = initialRepos.get(i);
initialRepos.set(i, description.replaceAll("\\s+", " "));
}
return initialRepos;
}

View File

@ -166,7 +166,7 @@ public class RepoProviderTest extends FDroidProviderTest {
assertRepo(
defaultRepos.get(i),
reposFromXml[offset + 1], // address
reposFromXml[offset + 2], // description
reposFromXml[offset + 2].replaceAll("\\s+", " "), // description
Utils.calcFingerprint(reposFromXml[offset + 7]), // pubkey
reposFromXml[offset] // name
);