Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
R
retypos-adapter
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Board
Labels
Milestones
CI / CD
CI / CD
Pipelines
Schedules
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
eterfund
retypos-adapter
Commits
f24c5ecb
Commit
f24c5ecb
authored
Aug 02, 2018
by
Jorgen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add preg_quote invokation to secure input data
parent
308b40b8
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
4 deletions
+5
-4
TyposClientInterface.php
src/TyposClientInterface.php
+5
-4
No files found.
src/TyposClientInterface.php
View file @
f24c5ecb
...
...
@@ -67,10 +67,13 @@ abstract class TyposClientInterface
* @param string $context Context where the typo found
* @param TyposArticle $article Article to fix the typo
*/
public
function
replaceTypoInArticle
(
string
$typo
,
string
$corrected
,
string
$context
,
TyposArticle
$article
)
{
public
function
replaceTypoInArticle
(
string
$typo
,
string
$corrected
,
string
$context
,
TyposArticle
$article
)
{
// Strip all tags from text
$text
=
strip_tags
(
$article
->
text
);
$context
=
preg_quote
(
$context
);
$typo
=
preg_quote
(
$typo
);
// Find all typos in text, capture an offset of each typo
$typos
=
[];
preg_match_all
(
"#
{
$typo
}
#"
,
$text
,
$typos
,
PREG_OFFSET_CAPTURE
);
...
...
@@ -80,14 +83,12 @@ abstract class TyposClientInterface
$contextMatch
=
[];
preg_match_all
(
"#
{
$context
}
#"
,
$text
,
$contextMatch
,
PREG_OFFSET_CAPTURE
);
error_log
(
"Context match = "
.
print_r
(
$contextMatch
,
true
));
$contextMatch
=
$contextMatch
[
0
];
if
(
!
isset
(
$contextMatch
[
0
]))
{
throw
new
\Exception
(
"Failed to find the context in article"
);
}
$contextOffset
=
$contextMatch
[
0
][
1
];
// Find a concrete typo that we want to fix
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment