Is there a way to get ProxyHTMLURLMap to match more than once per tag attribute? - linux

I have a problem that seems to be caused by resources being called with img tags that look like this:
<img
class="alignnone size-full"
title="some title"
src="https://new.url.com/some.jpeg" alt="" width="612" height="408"
srcset="https://new.url.com/some.jpeg 612w, https://old.url.com/some-300x200.jpg 300w"
sizes="(max-width: 612px) 100vw, 612px">
ProxyHTMLURLMap successfully replaces the first URL within the attribute "srcset" but never more than the first.
I don't see anything in the manual that could address this, any help is much appreciated.
I am interested in any open source Linux compatible solutions even if outside Apache.
Thanks!

I found a limited workaround for this issue.
If each ProxyHTMLURLMap can replace only one matched occurrence, we need to add more directives like that.
ProxyHTMLURLMap "https://old.url.com/" "https://new.url.com/" Rl
ProxyHTMLURLMap " https://old.url.com/" " https://new.url.com/" Rl
ProxyHTMLURLMap ", https://old.url.com/" ", https://new.url.com/" Rl
ProxyHTMLURLMap "w, https://old.url.com/" "w, https://new.url.com/" Rl
These four directives can replace up to 4 instances of https://old.url.com
"R" flag is needed to process regular expressions.
"l" flag is needed to avoid stopping after first (second, third) match occurs.
It seems to work for me.

Related

How to get only rely content (not included quote content) using Selenium

I want to know what to get some content not include quote content.
https://forumd.hkgolden.com/view.aspx?type=BW&message=7219211
The following picture is the example
I want to get only "唔提冇咩人記得", but I use the following code will get both content.
content = driver_blank.find_element_by_xpath('/html/body/form/div[5]/div/div/div[2]/div[1]/div[5]/table[24]/tbody/tr/td/table/tbody/tr/td[2]/table/tbody/tr[1]/td/div')
print(content.text)
The following code is what I want to capture content:
<div class="ContentGrid">
<blockquote><div style="color: #0000A0;"><blockquote><div style="color: #0000A0;">腦魔都俾你地bam咗啦<img data-icons=":~(" src="/faces/cry.gif" alt=":~("></div></blockquote><br>珠。。。。。</div></blockquote><br>唔提冇咩人記得
<br><br><br>
</div>
Can anyone help me? Thanks~~~
Can not(starts-with 's method be solved?
Use below line of code to extract only text node content
element = driver.find_element_by_css_selector('div.ContentGrid')
text = driver.execute_script("return arguments[0].childNodes[3].textContent", element);
print(text)
Selenium won't allow you to directly locate an element using text node. Though you can use some JavaScript code to make it happen.
Code Explanation:
arguments[0].childNodes[3] indicates 3rd child element of your context node which is div.ContentGrid. Please note first 2 child element of the context node are blank (tried with the HTML code shared by you) that's why index 3 used.

How to run pkgdown for YAML to take effect?

Can somebody please help me understanding how to change the url, and, for example, the author on pkgdown sites?
https://pkgdown.r-lib.org/reference/build_site.html
Hypothetically I placed this the yml as
inst/_pkgdown.yml
Adding these lines
url: http://iotables.ceemid.eu`
authors:
Daniel Antal, CFA:
href: "http://www.twitter.com/antaldaniel"`
And eventually I put in the setup options
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/"
#fig.path = "README-"
)
furthermore placed in README.Rmd
# iotables <img src="man/figures/logo.png" align="right" />
How I supposed to run pkgdown::build_site() or pkgdown::build_home() to take effect? Do I need to specify a list of override? If not, can I add this information in the override= parameter? How? This is completely unclear to me in the manual.
For some reason, I end up with a pkgdown.yml that is missing these information bits, and eventually the links are wrong on the resulting website.
I also struggled with this problem. It seems that a yml file is created and one is required for what you say above.
In short, I think that you need to put the _pkgdown.yml file into the pkgdown folder and not the inst folder. All should then work if you run pkgdown::build_site().
I hope this helps you.

Vim error E745 'Using a List as a Number' when creating `Latex` snippet in `neosnippet`

I am using neosnippet to create a snippet for a latex template. The snippet is rather long, and I keep getting a strange error E745 Using a List as a Number when I try to expand the snippet.
Here is the error message that neovim is putting out.
[dein] Error occurred while executing hook: neosnippet.vim
[dein] Vim(let):E745: Using a List as a Number
Error detected while processing function <SNR>346 snippets_expand ...
Line 11
E15: invalid expression:
E15: invalid expression
The actual snippet itself is below--it is quite long. Now when I take this long snippet out of the snippet file, all other snippets work fine. So it seems somewhere I am using a character I am not supposed to use or something. Or perhaps something is not properly escaped, etc.
All of my other latex snippets work just fine, but there are also much shorter. Does anyone have any ideas about why this snippet is causing so much trouble?
Here is the latex snippet.
\documentclass{book}
\addtolength{\topmargin}{-.5in}
\addtolength{\headsep}{.5in}
\oddsidemargin=.5in
\evensidemargin=.5in
\textwidth=5.5in
\usepackage{
amsmath,% AMS basic math stuff
amsthm,% AMS theorem defining stuff
amsfonts,% defines the blackboard bold fonts for \Z, \R, etc
longtable,% used to create the tcproof environment below
verbatim,% allows for verbatim output, and also covering up stuff in comments
xspace,% adds an extra space an the end of some commands
multicol,% allows multicolumn output
tikz,% creates the tikzpicture drawing environment
charter,% changes the default font to charter
framed,% used to color in the TIscreen environment below
bm,
mathrsfs}
\usepackage{pifont}
\usepackage[colorlinks,unicode]{hyperref}
\newcommand{\R}{\mathbb{R}}
\newcommand{\Q}{\mathbb{Q}}
\newcommand{\Z}{\mathbb{Z}}
\newcommand{\N}{\mathbb{N}}
\newcommand{\Tau}{\bm{\mathcal{T}}}
\newcommand{\Taup}{\bm{\mathcal{T}^{\prime}}}
\newcommand{\Bp}{\mathscr{B}^{\prime}}
\newcommand{\B}{\mathscr{B}}
\newcommand{\CCp}{\mathscr{C}^{\prime}}
\newcommand{\CC}{\mathscr{C}}
\newcommand{\Ltop}{\R_{\mathscr{L}}}
\newcommand{\Ktop}{\R_{\mathscr{K}}}
\DeclareMathOperator{\lcm}{lcm}
\newcommand{\cl}[1]{[#1]}
\newcommand{\st}{\mid}
\newcommand{\eq}{\stackrel{?}{=}}
\newcommand{\divq}{\stackrel{?}{|}}
\newcommand{\forwards}{\mbox{``$\Longrightarrow$''}\xspace}
\newcommand{\backwards}{\mbox{``$\Longleftarrow$''}\xspace}
\newcommand{\define}[1]{\textbf{#1}}
\newcommand{\threeven}{pretty\xspace}
\newcommand{\throd}{normal\xspace}
\newcommand{\throve}{ugly\xspace}
\DeclareMathSymbol{\nmid}{\mathrel}{AMSb}{"2D}
\newcommand{\notdiv}{\nmid}
\renewcommand{\tilde}{\widetilde}
\renewcommand{\thefootnote}{\fnsymbol{footnote}}
\def\endclass#1{\par\noindent\hrulefill\fbox{\tiny This is where we
ended on #1}\hrulefill\vskip 5pt plus 1pt\par }
\pagestyle{headings}
\makeatletter
\edef\today{%
\the\year/\two#digits{\the\month}/\two#digits{\the\day}}
\renewcommand{\#evenhead}{\emph{Ordinary Differential Equations - Arnold}
(v. \today)
\hfill Krishna Bhogaonker \hfill \thepage}
\renewcommand{\#oddhead}{(version \today) \hfill \thepage}
\makeatother
\DeclareMathSymbol{\varnothing}{\mathord}{AMSb}{"3F}
\renewcommand{\emptyset}{\varnothing}
\colorlet{shadecolor}{gray!35}
\newenvironment{TIscreen}
{\begin{center}\tt
\renewcommand{\in}[1]{##1\\}
\newcommand{\out}[1]{\mbox{}\hfill##1\\}
\begin{minipage}{2in}\begin{snugshade}}
{\end{snugshade}\end{minipage}\end{center}}
\newenvironment{tcproof}[1]
{\smallskip\par\begin{longtable}{#{}p{.45\textwidth}p{.45\textwidth}#{}}
\multicolumn{2}{#{}l}{\emph{#1}}\\[\smallskipamount]
Assertion & Justification \endfirsthead
Assertion & Justification \endhead
\hline }
{\end{longtable}\qed\smallskip\par}
\newtheorem{lemma}{Lemma}[section]
\newtheorem{theorem}[lemma]{Theorem}
\newtheorem{cor}[lemma]{Corollary}
\newtheorem*{scholium}{Scholium}
\theoremstyle{definition}
\newtheorem{definition}[lemma]{Definition}
\newtheorem{example}[lemma]{Example}
\newenvironment{comments}{}{}
\makeatletter
\define#key{hide}{scholium}[true]{\renewenvironment{scholium}{\comment}{\endcomment}}
\define#key{hide}{proof}[true]{\renewenvironment{proof}{\comment}{\endcomment}}
\define#key{hide}{lemma}[true]{\renewenvironment{lemma}{\comment}{\endcomment}}
\define#key{hide}{comments}[true]{\renewenvironment{comments}{\comment}{\endcomment}}
\define#key{hide}{cor}[true]{\renewenvironment{cor}{\comment}{\endcomment}}
\define#key{hide}{definition}[true]{\renewenvironment{definition}{\comment}{\endcomment}}
\define#key{hide}{example}[true]{\renewenvironment{example}{\comment}{\endcomment}}
\define#key{hide}{theorem}[true]{\renewenvironment{theorem}{\comment}{\endcomment}}
\newcommand{\HideEnvirons}[1]{\setkeys{hide}{#1}}
\define#key{show}{scholium}[true]{\define#key{hide}{scholium}{}}
\define#key{show}{proof}[true]{\define#key{hide}{proof}{}}
\define#key{show}{lemma}[true]{\define#key{hide}{lemma}{}}
\define#key{show}{comments}[true]{\define#key{hide}{comments}{}}
\define#key{show}{cor}[true]{\define#key{hide}{cor}{}}
\define#key{show}{definition}[true]{\define#key{hide}{definition}{}}
\define#key{show}{example}[true]{\define#key{hide}{example}{}}
\define#key{show}{theorem}[true]{\define#key{hide}{theorem}{}}
\newcommand{\ShowEnvirons}[1]
{\setkeys{show}{#1}\HideEnvirons{%
comments,
cor,
definition,
example,
proof,
theorem,
lemma,
scholium
}}
\makeatother
\begin{document}
\tableofcontents
\newpage
\chapter{Basic Concepts}
${0}
\end{document}
Okay, I talked to the developer and he indicated the problem had to do with the backquotes in this section of the document.
\newcommand{\forwards}{\mbox{````$\Longrightarrow$''}\xspace}
\newcommand{\backwards}{\mbox{````$\Longleftarrow$''}\xspace}
I updated the neosnippet plugin and also changed the latex code as well. Now things work fine.

How to assign multiple lines string in Powershell Console

When I do enter this in powershell Console
$test=#'
Test
Test'#
And do enter several times, it keeps printing
>>
So I can never finish command.
What to do ?
'# should be first thing in the line or it is considered to be just a part of the string.
$test=#'
Test
Test
'#
This approach also works with #"/"#
As per the section on maximum line length in The PowerShell Best Practices and Style Guide, I would suggest “splatting” the string, like this:
$myStr = ("The family of Dashwood had long been settled in Sussex. Their estate was " +
"large, and their residence was at Norland Park, in the centre of their " +
"property, where, for many generations, they had lived in so respectable " +
"a manner as to engage the general good opinion of their surrounding " +
"acquaintance.")
$test=#'
Test
Test
'#
The important thing to note is that the delimiters include (invisible) carriage returns. There must be one at the end of the starting tag, and one before the closing tag.

%2B decoding to a space instead of a plus

We have a problem in a specific server. All plus signs posted to the application are replaced with spaces - that's in POST and GET, and on all pages on that site.
As a test case I have this little page (it's an ASP server):
<html>
<body>
<form method="post">
<input type="text" name="Plus" id="Plus" />
<input type="submit" />
</form>
Previous Value: <%= request("Plus") %><br />
Query String: <%= request.querystring %>
</body>
</html>
On every other server this works well, but on one server pluses are replaced with spaces.
Example: for the input "1 2+3" - request("Plus") is "1 2 3", and the Query String is "1+2+3". No good. Other characters seem to be decoding correctly.
It should be said someone had tried to 'harden' this server against attacks, so obscure IIS options may be turned on (though we did remove the ISAPI filter).
Thanks.
UPDATE:
It turns out there's another filter installed, the SQL Injection Filter ISAPIClipSQLInjection.dll from http://www.codeplex.com/IIS6SQLInjection .
The filter is buggy - it replaces valid characters from POST and GET:
Plus signs are replaced with spaces: "1%2B2" -> "1+2", same as "1 2"
Semicolons are replaced with Commas: "hello;" -> "hello,"
A newer version of the filter (2.0b) does not fix this, but allows to exclude certain pages. Since it is installed in production we decided not to remove the filter, we used javascript to change all pluses to "&#43 " (with space and not a semicolon).
Not the optimal solution, but that's what the boss wanted.
Consider Ascii Code. In the place of a plus sign use its ascii code.It would be chr(43). Both asp and sql would understand this.
here is a table with all ascii codes.
http://www.asciitable.com/
Well, this also confused me. till I saw this post: Server.URLEncode started to replace blank with plus ("+") instead of percent-20 ("%20")
in short:
RFC-1866 (around 1995), declared that blank " " should be parsed to "+" in request body.
RFC-3986 (2005, Jan) declared that blank " "should be parsed to "%20"
and in ASP framework, it supports the RFC-1866, and sometimes mixed RFC-3986(seems) , so the parameter %2b firstly converted to + (normal ascii/urldecode rule , then it converted to ( RFC-1866 rule )
This is my guess, I don't care old-dead tech, for more details, see

Resources