Prevent an error, if OA_source is not defined
[openx] / openx.js
index bfd49a5..e074a9a 100644 (file)
--- a/openx.js
+++ b/openx.js
@@ -48,8 +48,9 @@
       });
     }
 
-    src += "&nz=1&source=" + escape(OA_source);
-    src += "&r=" + Math.floor(Math.random()*99999999);
+    if (typeof OA_source !== 'undefined')
+      src += "&source=" + escape(OA_source);
+    src += "&nz=1&r=" + Math.floor(Math.random()*99999999);
     src += "&block=1&charset=UTF-8";
 
     if (window.location)   src += "&loc=" + escape(window.location);
         }
         else {
           /** Remember iinline-code, if present */
-          src = result[1]
+          src = result[1] + ' ' // << simplifies the following regular expression: the string ends with a space in any case, so that the src-URL cannot be followed by the end of the string emediately!
           inline = result[2];
           /** Strip all text up to and including "</script>" from OA_output[id] */
           OA_output[id] = OA_output[id].slice(result[0].length,OA_output[id].length);
-          result = /src\s*=\s*['"]([^'"]*)['"]/i.exec(src);
+          result = /src\s*=\s*['"]?([^'"]*)['"]?\s/i.exec(src);
           if (result == null) {
             /** script-tag with inline-code: execute inline-code! */
             result = /^\s*<.*$/m.exec(inline);