-Поиск по дневнику

Поиск сообщений в rss_thedaily_wtf

 -Подписка по e-mail

 

 -Постоянные читатели

 -Статистика

Статистика LiveInternet.ru: показано количество хитов и посетителей
Создан: 06.04.2008
Записей:
Комментариев:
Написано: 0


CodeSOD: Utter Filth

Среда, 27 Января 2016 г. 14:30 + в цитатник

Terrell inherited some database stored procedures. Like all good, Enterprisey stored procedures, it was written in PL/SQL. Unlike most Enterprisey procedures, it had a clear purpose: to clean your dirty inputs.

The actual problem: based on user input, the PL/SQL code needed to write a temporary file to the filesystem. Since user input is full of filthy, illicit characters, this procedure needs to clean them up.

PROCEDURE p_clean_name (
      p_file_name             IN       VARCHAR2,
      p_file_name_end         OUT      VARCHAR2
   )
---------------------------------------------------------------------------------------------------
-- Purpose: Clean the file name removing all dirty characters
----------------------------------------------------------------------------------------------------
   IS
      l_function_name   VARCHAR2 (64) := 'p_clean_name';
   BEGIN
      p_file_name_end :=
         REPLACE
            (REPLACE
                (REPLACE
                    (REPLACE
                        (REPLACE
                            (REPLACE
                                (REPLACE
                                    (REPLACE
                                        (REPLACE
                                            (REPLACE
                                                (REPLACE
                                                    (REPLACE
                                                        (REPLACE
                                                            (REPLACE
                                                                (REPLACE
                                                                    (REPLACE
                                                                        (REPLACE
                                                                            (REPLACE
                                                                                (REPLACE
                                                                                    (REPLACE
                                                                                        (REPLACE
                                                                                            (REPLACE
                                                                                                (REPLACE
                                                                                                    (REPLACE
                                                                                                        (REPLACE
                                                                                                            (REPLACE
                                                                                                                (REPLACE
                                                                                                                    (REPLACE
                                                                                                                        (REPLACE
                                                                                                                            (REPLACE
                                                                                                                                (REPLACE
                                                                                                                                    (REPLACE
                                                                                                                                        (TRIM
                                                                                                                                            (p_file_name
                                                                                                                                            ),
                                                                                                                                         '/',
                                                                                                                                         '_'
                                                                                                                                        ),
                                                                                                                                     '*',
                                                                                                                                     '_'
                                                                                                                                    ),
                                                                                                                                 '%',
                                                                                                                                 '_'
                                                                                                                                ),
                                                                                                                             '`u',
                                                                                                                             '_'
                                                                                                                            ),
                                                                                                                         '`o',
                                                                                                                         '_'
                                                                                                                        ),
                                                                                                                     '`a',
                                                                                                                     '_'
                                                                                                                    ),
                                                                                                                 '`e',
                                                                                                                 '_'
                                                                                                                ),
                                                                                                             '`u',
                                                                                                             '_'
                                                                                                            ),
                                                                                                         '`i',
                                                                                                         '_'
                                                                                                        ),
                                                                                                     ''e',
                                                                                                     '_'
                                                                                                    ),
                                                                                                 '°',
                                                                                                 '_'
                                                                                                ),
                                                                                             '$',
                                                                                             '_'
                                                                                            ),
                                                                                         'lb',
                                                                                         '_'
                                                                                        ),
                                                                                     '&',
                                                                                     '_'
                                                                                    ),
                                                                                 '?',
                                                                                 '_'
                                                                                ),
                                                                             '§',
                                                                             '_'
                                                                            ),
                                                                         '^',
                                                                         '_'
                                                                        ),
                                                                     '(',
                                                                     '_'
                                                                    ),
                                                                 ')',
                                                                 '_'
                                                                ),
                                                             '\',
                                                             '_'
                                                            ),
                                                         '#',
                                                         '_'
                                                        ),
                                                     '+',
                                                     '_'
                                                    ),
                                                 '[',
                                                 '_'
                                                ),
                                             ']',
                                             '_'
                                            ),
                                         ';',
                                         '_'
                                        ),
                                     ':',
                                     '_'
                                    ),
                                 '@',
                                 '_'
                                ),
                             'c',
                             '_'
                            ),
                         '<',
                         '_'
                        ),
                     '>',
                     '_'
                    ),
                 '.',
                 '_'
                ),
             ' ',
             '_'
            );
   EXCEPTION
      WHEN OTHERS
      THEN
         p_handle_log ('X',
                      SQLCODE ||'-'|| SQLERRM || '- ' || DBMS_UTILITY.format_error_backtrace(),
                      l_function_name,
                      null,
                      null
                     );     
   END;

Well, something is dirty in here.

[Advertisement] BuildMaster is more than just an automation tool: it brings together the people, process, and practices that allow teams to deliver software rapidly, reliably, and responsibly. And it's incredibly easy to get started; download now and use the built-in tutorials and wizards to get your builds and/or deploys automated!

http://thedailywtf.com/articles/utter-filth

Метки:  

 

Добавить комментарий:
Текст комментария: смайлики

Проверка орфографии: (найти ошибки)

Прикрепить картинку:

 Переводить URL в ссылку
 Подписаться на комментарии
 Подписать картинку