r22388 by jghali -
scribus-commit
scribus-commit at lists.scribus.net
Tue Feb 13 22:45:38 UTC 2018
Author: jghali
Date: Tue Feb 13 22:45:38 2018
New Revision: 22388
URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=22388
Log:
#15145: Javascript fails to execute on PDF opening when PDF security is enabled
Modified:
branches/Version14x/Scribus/scribus/pdflib_core.cpp
branches/Version14x/Scribus/scribus/pdflib_core.h
Modified: branches/Version14x/Scribus/scribus/pdflib_core.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=22388&path=/branches/Version14x/Scribus/scribus/pdflib_core.cpp
==============================================================================
--- branches/Version14x/Scribus/scribus/pdflib_core.cpp (original)
+++ branches/Version14x/Scribus/scribus/pdflib_core.cpp Tue Feb 13 22:45:38 2018
@@ -805,6 +805,7 @@
QFileInfo fd;
QString fext;
int a;
+ int openActionObj = 0;
inPattern = 0;
Bvie = vi;
BookMinUse = false;
@@ -863,7 +864,8 @@
PutDoc("/PageMode /UseOC\n");
if (!Options.openAction.isEmpty())
{
- PutDoc("/OpenAction << /S /JavaScript /JS (this."+Options.openAction+"\\(\\)) >>\n");
+ openActionObj = newObject();
+ PutDoc("/OpenAction << /S /JavaScript /JS " + QString::number(openActionObj) + " 0 R >>\n");
}
QDate d = QDate::currentDate();
@@ -985,6 +987,10 @@
PutDoc("/O <"+String2Hex(&ok)+">\n");
PutDoc("/U <"+String2Hex(&uk)+">\n");
PutDoc("/P "+QString::number(Options.Permissions)+"\n>>\nendobj\n");
+ }
+ if (openActionObj)
+ {
+ WritePDFString("this." + Options.openAction + "()", openActionObj);
}
QMap<QString, QMap<uint, FPointArray> > ReallyUsed;
ReallyUsed.clear();
@@ -6482,6 +6488,19 @@
return result;
}
+uint PDFLibCore::WritePDFStream(const QString& cc, uint objNum)
+{
+ QString tmp(cc);
+ if (Options.Compress)
+ tmp = CompressStr(&tmp);
+ StartObj(objNum);
+ PutDoc("<< /Length "+QString::number(tmp.length())); // moeglicherweise +1
+ if (Options.Compress)
+ PutDoc("\n/Filter /FlateDecode");
+ PutDoc(" >>\nstream\n"+EncStream(tmp, objNum)+"\nendstream\nendobj\n");
+ return objNum;
+}
+
uint PDFLibCore::WritePDFString(const QString& cc)
{
QString tmp;
@@ -6497,6 +6516,23 @@
tmp += cc[i];
}
return WritePDFStream(tmp);
+}
+
+uint PDFLibCore::WritePDFString(const QString& cc, uint objNum)
+{
+ QString tmp;
+ for (int i = 0; i < cc.length(); ++i)
+ {
+ if (cc[i].unicode() > 255)
+ {
+ tmp += "\\u";
+ tmp += toHex(cc[i].row());
+ tmp += toHex(cc[i].cell());
+ }
+ else
+ tmp += cc[i];
+ }
+ return WritePDFStream(tmp, objNum);
}
void PDFLibCore::PDF_xForm(uint objNr, double w, double h, QString im)
Modified: branches/Version14x/Scribus/scribus/pdflib_core.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=22388&path=/branches/Version14x/Scribus/scribus/pdflib_core.h
==============================================================================
--- branches/Version14x/Scribus/scribus/pdflib_core.h (original)
+++ branches/Version14x/Scribus/scribus/pdflib_core.h Tue Feb 13 22:45:38 2018
@@ -141,7 +141,9 @@
void StartObj(int nr);
uint newObject() { return ObjCounter++; }
uint WritePDFStream(const QString& cc);
+ uint WritePDFStream(const QString& cc, uint objNum);
uint WritePDFString(const QString& cc);
+ uint WritePDFString(const QString& cc, uint objNum);
void writeXObject(uint objNr, QString dictionary, QByteArray stream);
uint writeObject(QString type, QString dictionary);
uint writeGState(QString dictionary) { return writeObject("/ExtGState", dictionary); }
More information about the scribus-commit
mailing list