By choosing Load '.$noun.', you agree to connect to '.$name.', which may receive connection data and use cookies or similar storage.'.$privacy.'
'.$link.'';
};
$fsm_attrs = '(?:[^>"\']|"[^"]*"|\'[^\']*\')*';
$fsm_active = static function () {return is_singular(array('post','page')) && in_the_loop() && is_main_query();};
/* Early: stored article scripts are not safe player containers. Do not execute
or re-inject them. Global theme/plugin scripts and head/footer ads are not
touched. This runs before normal shortcode / content rendering. */
add_filter('the_content', static function ($html) use ($fsm_attrs,$fsm_active,$fsm_source,$fsm_name,$fsm_panel) {
if (!$fsm_active() || stripos($html,'~is';
$out=preg_replace_callback($pattern,static function($m) use($fsm_source,$fsm_name,$fsm_panel){
$t=new WP_HTML_Tag_Processor($m[0]); if (!$t->next_tag()) return '';
$type=strtolower(trim((string)$t->get_attribute('type')));
// Keep inert JSON metadata and code/data script types, not executable modules.
if (in_array($type,array('application/ld+json','application/json','text/plain'),true) && !$t->get_attribute('src')) return $m[0];
$s=$fsm_source($t->get_attribute('src'));
if ($s && !$s['local']) {
if ($s['host']==='platform.twitter.com' && (wp_parse_url($s['url'],PHP_URL_PATH)==='/widgets.js')) return '';
if (preg_match('~(?:^|\.)(?:chitika\.(?:net|com)|bidvertiser\.com)$~i',$s['host'])) return '';
// Verge embeds also have a frame; avoid duplicating its placeholder.
if ($s['host']==='assets.theverge.vid.io') return '';
return $fsm_panel(array('provider'=>$fsm_name($s['host']),'script_only'=>true));
}
return ''; // inline executable code or local script with unknown outward requests
},$html);
return is_string($out)?$out:$html;
},1);
/* Late: suppress known player bootstrap scripts emitted during shortcode
rendering. Do not blanket-remove scripts inserted by other plugins. */
add_filter('the_content', static function ($html) use ($fsm_attrs,$fsm_active,$fsm_source,$fsm_hosts) {
if (!$fsm_active() || stripos($html,'~is';
$out=preg_replace_callback($pattern, static function($m) use($fsm_source,$fsm_hosts){
$t=new WP_HTML_Tag_Processor($m[0]); if(!$t->next_tag()) return $m[0];
$s=$fsm_source($t->get_attribute('src')); if(!$s || $s['local']) return $m[0];
$p=wp_parse_url($s['url']); $path=$p['path']??'';
if ($s['host']==='platform.twitter.com' && $path==='/widgets.js') return '';
foreach(array('ooyala.com','vid.io','player.vimeo.com','w.soundcloud.com','geo.dailymotion.com','player.twitch.tv','embed.twitch.tv','player.ex.co') as $d) if($fsm_hosts($s['host'],$d)) return '';
if (($fsm_hosts($s['host'],'youtube.com') && preg_match('~/(?:iframe_api|player_api)(?:/|$)~',$path)) || ($fsm_hosts($s['host'],'spotify.com') && strpos($path,'/embed/iframe-api')===0)) return '';
return $m[0];
},$html);
return is_string($out)?$out:$html;
},99997);
add_filter('the_content', static function ($html) use ($fsm_attrs,$fsm_active,$fsm_source,$fsm_convert,$fsm_name,$fsm_panel) {
if (!$fsm_active() || !preg_match('~<(?:iframe|object|embed|video|audio)\b~i',$html)) return $html;
/* Before output reaches browser. Code examples should be escaped HTML;
actual active tags inside pre/code are still intercepted. */
$pattern='~(*SKIP)(*F)|<(script|style|textarea|xmp|title)\b'.$fsm_attrs.'>.*?\1\s*>(*SKIP)(*F)|<(object|video|audio)\b'.$fsm_attrs.'>.*?\2\s*>|)?|<(?:embed|object|video|audio)\b'.$fsm_attrs.'>~is';
$out=preg_replace_callback($pattern,static function($m) use($fsm_source,$fsm_convert,$fsm_name,$fsm_panel){
$raw=$m[0]; $t=new WP_HTML_Tag_Processor($raw); if(!$t->next_tag()) return $raw;
$tag=$t->get_tag(); $native=in_array($tag,array('VIDEO','AUDIO'),true);
$external=array(); $local=false; $invalid=false; $media=array(); $poster=''; $tracks=array(); $provider='external provider';
// srcdoc is arbitrary nested HTML, not safe to restore as an embed.
if ($tag==='IFRAME' && $t->get_attribute('srcdoc')!==null) return $fsm_panel(array('provider'=>'embedded document'));
do {
$node=$t->get_tag(); $names=array();
if (in_array($node,array('IFRAME','EMBED','VIDEO','AUDIO','SOURCE','TRACK'),true)) $names=array('src','data-src','data-lazy-src','data-original','data-url','data-lazyload-src');
elseif($node==='OBJECT') $names=array('data','data-src','src');
elseif($node==='PARAM' && in_array(strtolower((string)$t->get_attribute('name')),array('movie','src'),true)) $names=array('value');
if ($native && $node==='VIDEO') $names[]='poster';
foreach($names as $attr){
$value=$t->get_attribute($attr); if($value===null || $value==='') continue;
if (is_string($value) && in_array(strtolower(trim($value)),array('about:blank','about:srcdoc'),true)) continue;
$s=$fsm_source($value); if(!$s){$invalid=true;continue;}
if($s['local']) $local=true;
else {$external[]=$s; $provider=$fsm_name($s['host']);}
if ($native) {
// HTTPS only for external resources; local paths are preserved.
if (!$s['local'] && !$s['https'] && !preg_match('~(?:^|\.)apple\.com$~i',$s['host'])) continue;
$u=preg_replace('~^http:~i','https:',$s['url']);
if($attr==='poster') $poster=$u;
elseif($node==='TRACK') $tracks[]=array('src'=>$u,'kind'=>(string)$t->get_attribute('kind'),'label'=>(string)$t->get_attribute('label'),'srclang'=>(string)$t->get_attribute('srclang'));
elseif(in_array($node,array('VIDEO','AUDIO','SOURCE'),true)) $media[]=array('src'=>$u,'type'=>(string)$t->get_attribute('type'));
}
}
} while($t->next_tag());
if (!$external && !$invalid && $local) return $raw;
// Source-less native video/audio cannot request media and is left alone;
// source-less frames and objects can be dynamically populated, so gate them.
if (!$external && !$invalid && $native) return $raw;
if ($native && $media && !$invalid) return $fsm_panel(array('provider'=>$provider,'kind'=>strtolower($tag),'sources'=>array_values(array_unique($media,SORT_REGULAR)),'poster'=>$poster,'tracks'=>$tracks,'watch'=>''));
if (!$native && !$invalid) foreach($external as $s){$v=$fsm_convert($s,$tag);if($v)return $fsm_panel($v);}
return $fsm_panel(array('provider'=>$provider));
},$html);
return is_string($out)?$out:$html;
},99999);
/* FSM external images and X posts v5. No original remote image markup is
emitted for a gated image. Each gate owns its own payload and lifecycle.
Scope remains the singular main-loop content, not feeds or global assets. */
$fsm_image_source = static function ($value) use ($fsm_source) {
if (!is_string($value)) return null;
$value=trim($value);
// Inline raster images do not require a network connection.
if (preg_match('~^data:image/(?:png|gif|jpe?g|webp|avif|bmp|x-icon|vnd\.microsoft\.icon);base64,[a-z0-9+/=\s]+$~iD',$value)) return array('local'=>true,'url'=>$value,'host'=>'','https'=>true);
return $fsm_source($value);
};
// Tokenize srcset URLs separately from their width/density descriptors.
// A comma inside an URL (including data:) is not automatically a separator.
$fsm_srcset_urls = static function ($value) {
$urls=array();
while (is_string($value) && preg_match('~^[\s,]*([^\s]+)(.*)$~sD',$value,$m)) {
$token=$m[1]; $value=$m[2]; $urls[]=rtrim($token,',');
if (substr($token,-1)===',') continue;
$comma=strpos($value,','); if ($comma===false) break;
$value=substr($value,$comma+1);
}
return $urls;
};
$fsm_img_attrs=array('src','srcset','data-src','data-srcset','data-lazy-src','data-lazy-srcset','data-original','data-original-src','data-original-srcset','data-lazyload-src','data-lazyload-srcset','data-url','data-litespeed-src','data-litespeed-srcset','data-ll-src','data-ll-srcset','data-echo','data-retina','data-hi-res-src');
$fsm_image_gate = static function ($raw,$no_js=false) use ($fsm_image_source,$fsm_srcset_urls,$fsm_img_attrs,$fsm_source) {
$t=new WP_HTML_Tag_Processor($raw); $remote=array(); $preferred=array(); $invalid=false; $alt=''; $width=0; $height=0; $found=false; $link=''; $link_external=false;
while ($t->next_tag()) {
$tag=$t->get_tag();
if ($tag==='A' && !$found) {
$href=$fsm_source($t->get_attribute('href'));
if ($href) { $link=$href['url']; $link_external=!$href['local']; }
}
if (!in_array($tag,array('IMG','SOURCE','PICTURE'),true)) continue;
if ($tag==='IMG') {
if (!$found) {
$alt=(string)$t->get_attribute('alt');
foreach (array('width','height') as $dim) {
$val=$t->get_attribute($dim);
if (is_string($val) && preg_match('~^[1-9][0-9]{0,4}$~D',$val)) $$dim=(int)$val;
}
}
$found=true;
}
foreach ($fsm_img_attrs as $attr) {
$v=$t->get_attribute($attr); if ($v===null || $v==='') continue;
$urls=strpos($attr,'srcset')!==false ? $fsm_srcset_urls($v) : array($v);
foreach ($urls as $u) {
$s=$fsm_image_source($u);
if (!$s) { $invalid=true; continue; }
if (!$s['local']) {
$remote[]=$s;
if ($tag==='IMG' && strpos($attr,'srcset')===false) $preferred[]=$s;
}
}
}
// Review image-specific inline CSS. Do not replay remote backgrounds
// or unknown CSS on the reconstructed image. Other CSS is unchanged.
$style=$t->get_attribute('style');
if (is_string($style) && preg_match_all('~url\s*\(\s*(?:"([^"]*)"|\'([^\']*)\'|([^)]*))\s*\)~i',$style,$matches,PREG_SET_ORDER|PREG_UNMATCHED_AS_NULL)) {
foreach ($matches as $m) {
$s=$fsm_image_source(trim($m[1]??$m[2]??$m[3]??''));
if (!$s) $invalid=true; elseif (!$s['local']) $remote[]=$s;
}
}
}
if (!$remote && !$invalid) return $raw;
// One explicit request, one image URL. Do not restore alternate srcset,
// picture, arbitrary data attributes, styles, handlers or remote previews.
$selected=null;
foreach (array_merge($preferred,$remote) as $s) if ($s['https']) { $selected=$s; break; }
$fallback=$selected ?? ($remote[0]??null);
$url=$fallback['url']??''; $host=$fallback['host']??'';
$fireplace=$url==='https://github.com/dolsup/cli-fireplace/raw/master/cli-fireplace-demo.gif?raw=true';
if ($fireplace && $alt==='') $alt='Animated Fireplace terminal demonstration';
$direct=$url?'Open original image ↗':'';
$original_link=$link?'Open linked page ↗':'';
if ($no_js) return 'External image not loaded. '.$direct.$original_link.'';
$out='EXTERNAL IMAGE'.($host?' / '.esc_html(strtoupper($host)):'').'Image blocked for your privacy';
if ($alt!=='') $out.=''.esc_html($alt).'';
if ($selected) {
$cfg=array('kind'=>'image','url'=>$selected['url'],'alt'=>$alt,'width'=>$width,'height'=>$height);
$out.='Loading connects to '.esc_html($host).' and may also contact redirect destinations. They receive connection data and may use cookies.'.($fireplace?' This animated GIF is approximately 20 MB.':'').'';
} else $out.='No supported HTTPS image URL is available for in-page loading.';
return $out.$direct.$original_link.'';
};
$fsm_images = static function ($html,$no_js=false) use ($fsm_attrs,$fsm_image_gate,&$fsm_images) {
// Whole picture / image-only link / noscript fallback units are handled
// before individual tags. Skip comments and text-only/raw-text elements.
$picture='.*?';
$img='';
$pattern='~(*SKIP)(*F)|<(script|style|textarea|xmp|title)\b'.$fsm_attrs.'>.*?\1\s*>(*SKIP)(*F)||\s*(?:'.$picture.'|'.$img.')\s*|'.$picture.'|'.$img.'||?[a-z][a-z0-9:-]*\b'.$fsm_attrs.'>(*SKIP)(*F)~is';
$out=preg_replace_callback($pattern,static function($m) use ($fsm_image_gate,$no_js,$fsm_attrs,&$fsm_images) {
if (preg_match('~^$~isD',$m[0],$inner)) {
// The Tag Processor treats NOSCRIPT as raw text in some versions.
// Examine its inner HTML separately, and retain local fallbacks.
$clean=$fsm_images($inner[1],true);
return $clean===$inner[1]?$m[0]:'';
}
// Standalone source tags belong to native video/audio too. Leave
// src-only ones to v4; a stray responsive source is not needed.
if (preg_match('~^next_tag()) return $m[0];
$responsive=false;
foreach (array('srcset','data-srcset','data-lazy-srcset','data-lazyload-srcset','data-original-srcset') as $a) if ($t->get_attribute($a)!==null) $responsive=true;
if (!$responsive) return $m[0];
$checked=$fsm_image_gate($m[0],true);
return $checked===$m[0]?$m[0]:'';
}
return $fsm_image_gate($m[0],$no_js);
},$html);
// A regex engine failure must not expose the original active image HTML.
// Rare error fallback: readable text, not a database change.
return is_string($out)?$out:'
Some formatting and media could not be safely displayed.
'.esc_html(wp_strip_all_tags($html)).'
';
};
add_filter('the_content',static function($html) use ($fsm_active,$fsm_images) {
if (!$fsm_active() || !preg_match('~<(?:img|picture|source|noscript)\b~i',$html)) return $html;
return $fsm_images($html);
},100000);
$fsm_tweet_url=static function($value) use ($fsm_source) {
$s=$fsm_source($value); if (!$s || $s['local']) return '';
if (!in_array($s['host'],array('twitter.com','www.twitter.com','mobile.twitter.com','x.com','www.x.com','mobile.x.com'),true)) return '';
$p=wp_parse_url($s['url']); if (isset($p['port'])) return '';
if (!preg_match('~^/(?:[A-Za-z0-9_]{1,15}/status|i/web/status)/([0-9]{1,25})/?$~D',$p['path']??'',$m)) return '';
return 'https://'.(($s['host']==='x.com'||str_ends_with($s['host'],'.x.com'))?'x.com':'twitter.com').rtrim($p['path'],'/');
};
add_filter('the_content',static function($html) use ($fsm_active,$fsm_attrs,$fsm_tweet_url) {
if (!$fsm_active() || stripos($html,'twitter-')===false) return $html;
$pattern='~(*SKIP)(*F)|<(script|style|textarea|xmp|title)\b'.$fsm_attrs.'>.*?\1\s*>(*SKIP)(*F)|
.*?
|?[a-z][a-z0-9:-]*\b'.$fsm_attrs.'>(*SKIP)(*F)~is';
$out=preg_replace_callback($pattern,static function($m) use ($fsm_tweet_url) {
$t=new WP_HTML_Tag_Processor($m[0]); if (!$t->next_tag()) return $m[0];
$classes=preg_split('~\s+~',trim((string)$t->get_attribute('class')));
if (!array_intersect($classes,array('twitter-tweet','twitter-video'))) return $m[0];
// Keep the original static quote and links, but remove auto-upgrade classes.
$t->remove_class('twitter-tweet'); $t->remove_class('twitter-video'); $t->add_class('fsm-twitter-static');
$quote=$t->get_updated_html(); $url='';
$t=new WP_HTML_Tag_Processor($m[0]);
while ($t->next_tag('A')) { $valid=$fsm_tweet_url($t->get_attribute('href')); if ($valid) $url=$valid; }
if (!$url) return $quote; // No invented ID or remote lookup.
$cfg=esc_attr(wp_json_encode(array('kind'=>'tweet','url'=>$url),JSON_UNESCAPED_SLASHES));
return $quote.'EXTERNAL POST / TWITTER (X)Live post blocked for your privacyLoading connects to X, which may receive connection data and use cookies or similar storage. The original quote remains above. Provider privacy information.View on X ↗';
},$html);
return is_string($out)?$out:$html;
},100001);
add_action('wp_footer',static function(){ ?>
"\']|"[^"]*"|\'[^\']*\')*';
$pattern = '~(*SKIP)(*F)|<(style|textarea|xmp|title)\b' . $attrs . '>.*?\1\s*>(*SKIP)(*F)|~is';
$clean = preg_replace_callback($pattern, static function ($m) {
/* Read actual attribute names, not quoted text in other attributes. */
preg_match_all('~([^\s=/<>"\']+)(?:\s*=\s*(?:"([^"]*)"|\'([^\']*)\'|([^\s>]+)))?~s', $m[2], $attributes, PREG_SET_ORDER | PREG_UNMATCHED_AS_NULL);
foreach ($attributes as $attribute) {
if (strtolower($attribute[1]) !== 'src') continue;
$src = trim(html_entity_decode($attribute[2] ?? $attribute[3] ?? $attribute[4] ?? '', ENT_QUOTES | ENT_HTML5, 'UTF-8'));
if (strpos($src, '//') === 0) $src = 'https:' . $src;
$host = strtolower((string) wp_parse_url($src, PHP_URL_HOST));
if ($host === 'chitika.net' || str_ends_with($host, '.chitika.net') || $host === 'chitika.com' || str_ends_with($host, '.chitika.com')) return '';
return $m[0];
}
/* Match the specific inline legacy ad configuration in FSM's export. */
$body = $m[3];
if (preg_match('~\bch_client\s*=\s*["\']murdamw["\']~i', $body)
&& preg_match('~\bch_type\s*=\s*["\']mpu["\']~i', $body)
&& preg_match('~\bch_width\s*=~i', $body)
&& preg_match('~\bch_height\s*=~i', $body)
&& preg_match('~\bch_queries\s*=~i', $body)) return '';
return $m[0];
}, $html);
return is_string($clean) ? $clean : $html;
}, 99998);
}
?>
TomTom iPhone App: Available in New Zealand’s AppStore
Waiting for the iPhone version of TomTom has an end. The navigation package is now available in four variants in New Zealand’s App Store: Western Europe (85 euros / $121), USA & Canada (60 euros / $100), New Zealand (60 euros / $100 ) and Australia (50 euros / $70).
When would it be available in the other appstores? We dont know, but FSMdotCOM will keep you updated. Stay tuned…