]> git.lyx.org Git - features.git/commitdiff
fix bug 1235
authorGeorg Baum <Georg.Baum@post.rwth-aachen.de>
Wed, 5 Apr 2006 08:19:48 +0000 (08:19 +0000)
committerGeorg Baum <Georg.Baum@post.rwth-aachen.de>
Wed, 5 Apr 2006 08:19:48 +0000 (08:19 +0000)
* src/support/filetools.C
(readBB_from_PSFile): sanitize return value

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@13549 a592a061-630c-0410-9148-cb99ea01b6c8

src/support/filetools.C

index f1a31e86cb64b22bd00c814677e4255c74877b31..e45208b98507476fecbbb7ec80c666374e81327a 100644 (file)
@@ -1172,12 +1172,22 @@ string const readBB_from_PSFile(string const & file)
                return string();
        }
 
+       static boost::regex bbox_re(
+               "^%%BoundingBox:\\s*([[:digit:]]+)\\s+([[:digit:]]+)\\s+([[:digit:]]+)\\s+([[:digit:]]+)");
        std::ifstream is(file_.c_str());
        while (is) {
                string s;
                getline(is,s);
-               if (contains(s,"%%BoundingBox:") && !contains(s,"atend")) {
-                       string const bb = ltrim(s.substr(14));
+               boost::smatch what;
+               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);
                        return bb;
                }