$OpenBSD: patch-src_video_cpp,v 1.1 2014/02/07 16:07:12 dcoppa Exp $

Fix some videos not playing
(upstream git commit df5f6436f59a3ce7abdb14427188f6360753a1e2)

--- src/video.cpp.orig	Thu Dec 19 00:37:27 2013
+++ src/video.cpp	Fri Feb  7 16:45:21 2014
@@ -28,6 +28,10 @@ namespace The {
 NetworkAccess* http();
 }
 
+namespace {
+    static const QString jsNameChars = "a-zA-Z0-9\\$_";
+}
+
 Video::Video() : m_duration(0),
     m_viewCount(-1),
     definitionCode(0),
@@ -390,7 +394,7 @@ void Video::gotHeadHeaders(QNetworkReply* reply) {
 
 void Video::parseJsPlayer(QByteArray bytes) {
     QString js = QString::fromUtf8(bytes);
-    QRegExp funcNameRe("signature=([a-zA-Z0-9]+)");
+    QRegExp funcNameRe("signature=([" + jsNameChars + "]+)");
     if (funcNameRe.indexIn(js) == -1) {
         qWarning() << "Cannot capture signature function name";
     } else {
@@ -402,7 +406,7 @@ void Video::parseJsPlayer(QByteArray bytes) {
 }
 
 void Video::captureFunction(const QString &name, const QString &js) {
-    QRegExp funcRe("function\\s+" + name + "\\s*\\([a-zA-Z0-9,\\s]*\\)\\s*\\{[^\\}]+\\}");
+    QRegExp funcRe("function\\s+" + QRegExp::escape(name) + "\\s*\\([" + jsNameChars + ",\\s]*\\)\\s*\\{[^\\}]+\\}");
     if (funcRe.indexIn(js) == -1) {
         qWarning() << "Cannot capture function" << name;
         return;
@@ -411,7 +415,7 @@ void Video::captureFunction(const QString &name, const
     sigFunctions.insert(name, func);
 
     // capture inner functions
-    QRegExp invokedFuncRe("[\\s=;\\(]([a-zA-Z0-9]+)\\s*\\([a-zA-Z0-9, ]+\\)");
+    QRegExp invokedFuncRe("[\\s=;\\(]([" + jsNameChars + "]+)\\s*\\([" + jsNameChars + ",\\s]+\\)");
     int pos = name.length() + 9;
     while ((pos = invokedFuncRe.indexIn(func, pos)) != -1) {
         QString funcName = invokedFuncRe.cap(1);
