fix bug 1235

* src/support/filetools.C
	(readBB_from_PSFile): sanitize return value


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/branches/BRANCH_1_4_X@13550 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Georg Baum 2006-04-05 09:13:32 +00:00
parent 15df5a0a83
commit 29d5aa8d82

View File

@ -1192,12 +1192,22 @@ string const readBB_from_PSFile(string const & file)
return string(); return string();
} }
static boost::regex bbox_re(
"^%%BoundingBox:\\s*([[:digit:]]+)\\s+([[:digit:]]+)\\s+([[:digit:]]+)\\s+([[:digit:]]+)");
std::ifstream is(file_.c_str()); std::ifstream is(file_.c_str());
while (is) { while (is) {
string s; string s;
getline(is,s); getline(is,s);
if (contains(s,"%%BoundingBox:") && !contains(s,"atend")) { boost::smatch what;
string const bb = ltrim(s.substr(14)); if (regex_match(s, what, bbox_re)) {
// Our callers expect the tokens in the string
// separated by single spaces.
// FIXME: change return type from string to something
// sensible
ostringstream os;
os << what.str(1) << ' ' << what.str(2) << ' '
<< what.str(3) << ' ' << what.str(4);
string const bb = os.str();
readBB_lyxerrMessage(file_, zipped, bb); readBB_lyxerrMessage(file_, zipped, bb);
return bb; return bb;
} }