parse links more cautiously

git-svn-id: https://public-transport-enabler.googlecode.com/svn/trunk@115 0924bc21-9374-b0fa-ee44-9ff1593b38f0
This commit is contained in:
andreas.schildbach 2010-08-29 09:50:25 +00:00
parent e28029c8df
commit 53d0d688fe
4 changed files with 30 additions and 19 deletions

View file

@ -222,16 +222,19 @@ public class RmvProvider implements NetworkProvider
return queryConnections(uri, page);
}
private static final Pattern P_CONNECTIONS_HEAD = Pattern.compile(".*" //
+ "Von: <b>(.*?)</b>.*?" //
+ "Nach: <b>(.*?)</b>.*?" //
+ "Datum: .., (\\d+\\..\\d+\\.\\d+).*?" //
+ "(?:<a href=\"(http://www.rmv.de/auskunft/bin/jp/query.exe/dox.*?REQ0HafasScrollDir=2)\">Fr&#252;her.*?)?" //
+ "(?:<a href=\"(http://www.rmv.de/auskunft/bin/jp/query.exe/dox.*?REQ0HafasScrollDir=1)\">Sp&#228;ter.*?)?", Pattern.DOTALL);
private static final Pattern P_CONNECTIONS_HEAD = Pattern.compile(".*?" //
+ "Von: <b>(.*?)</b>.*?" // from
+ "Nach: <b>(.*?)</b>.*?" // to
+ "Datum: .., (\\d+\\..\\d+\\.\\d+).*?" // currentDate
+ "(?:<a href=\"(http://www.rmv.de/auskunft/bin/jp/query.exe/dox[^\"]*?REQ0HafasScrollDir=2)\".*?)?" // linkEarlier
+ "(?:<a href=\"(http://www.rmv.de/auskunft/bin/jp/query.exe/dox[^\"]*?REQ0HafasScrollDir=1)\".*?)?" // linkLater
, Pattern.DOTALL);
private static final Pattern P_CONNECTIONS_COARSE = Pattern.compile("<p class=\"con(?:L|D)\">(.+?)</p>", Pattern.DOTALL);
private static final Pattern P_CONNECTIONS_FINE = Pattern.compile(".*?<a href=\"(http://www.rmv.de/auskunft/bin/jp/query.exe/dox.*?)\">" // url
private static final Pattern P_CONNECTIONS_FINE = Pattern.compile(".*?" //
+ "<a href=\"(http://www.rmv.de/auskunft/bin/jp/query.exe/dox[^\"]*?)\">" // link
+ "(\\d+:\\d+)-(\\d+:\\d+)</a>" //
+ "(?:&nbsp;(.+?))?", Pattern.DOTALL);
+ "(?:&nbsp;(.+?))?" //
, Pattern.DOTALL);
private QueryConnectionsResult queryConnections(final String uri, final CharSequence page) throws IOException
{